Reputation: 3684
I stumbled upon problems using authenticated connection. I wan't to retrive private posts that are tagged with specific tag. Currently, I am receiving status 200 with empty error message and can't do anything more. The code (almost same as in your docs:
$request_data = http_build_query(array('email'=>$thumblr['email'],'password'=>$thumblr['pass']));
//$c = curl_init("http://".$thumblr['acc_name'].".tumblr.com/api/read?tagged=".$thumblr['the_tag']);
$c = curl_init("http://www.tumblr.com/api/authenticate");
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $request_data);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($c);
$status = curl_getinfo($c, CURLINFO_HTTP_CODE);
curl_close($c);
if ($status == 201) {
echo "Success! The new post ID is $result.\n";
} else if ($status == 403) {
echo 'Bad email or password';
} else {
echo "Error [$status]: $result\n";
}
And output is:
Error [200]:
Help? :)
Upvotes: 1
Views: 1865
Reputation: 3684
Damnit, I got it by myself...
$request_data = http_build_query(
array(
'email' =>$thumblr['email'],
'password' =>$thumblr['pass'],
'id' =>$thumblr['header_id'],
'tagged' =>$thumblr['the_tag']
)
);
$c = curl_init('http://'.$thumblr['acc_name'].'.tumblr.com/api/read');
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $request_data);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($c);
$status = curl_getinfo($c, CURLINFO_HTTP_CODE);
curl_close($c);
switch ($status) {
case '200': $msg = 'OK'; break;
case '201': $msg = "Created - Success! The new post ID is $result.\n"; break;
case '400': $msg = 'Bad Request - There was at least one error while trying to save your post.'; break;
case '403': $msg = 'Forbidden - Your email address or password were incorrect.'; break;
default: $msg = $result; break;
}
echo '<p>'.$msg.'</p><pre>'.print_r($result,1).'</pre>';
Upvotes: 2