【发布时间】:2011-08-24 07:13:54
【问题描述】:
谁能帮我弄清楚如何使用 php 发布到 tumblr。 我尝试在谷歌上搜索库或示例代码,但找不到。我只能在这里找到https://github.com/alexdunae/tumblr-php/blob/master/Tumblr.php,它似乎也不起作用我在 tumblr 网站上查看并尝试了 v1 api 上的代码,但也不起作用....
function post($data){
if(function_exists("curl_version")){
$data["email"] = $this->email;
$data["password"] = $this->password;
$data["generator"] = $this->generator;
$request = http_build_query($data);
$c = curl_init('http://www.tumblr.com/api/write');
curl_setopt($c,CURLOPT_POST,true);
curl_setopt($c,CURLOPT_POSTFIELDS,$request);
curl_setopt($c,CURLOPT_RETURNTRANSFER,true);
$return = curl_exec($c);
$status = curl_getinfo($c,CURLINFO_HTTP_CODE);
curl_close($c);
if($status == "201"){
return true;
}
elseif($status == "403"){
return false;
}
else{
return "error: $return";
}
}
else{
return "error: cURL not installed";
}
}
感谢您的帮助
【问题讨论】:
-
总是阅读官方文档,通常位于官方网站,tumblr.com/docs/en/api