如何使用 tumblrAPI V2 oauth php 添加新帖子
$request_data = http_build_query(
array(
'oauth_token' => 'xxx',
'api_key' => 'xxx',
'type' => 'hello',
'title' => 'this is title',
'body' => 'this is body',
'generator' => 'API example'
)
);
// Send the POST request (with cURL)
$c = curl_init('http://api.tumblr.com/v2/blog/abc.tumblr.com/post');
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);
但不跑... 请帮我!
$request_data = http_build_query(
array(
'oauth_token' => 'xxx',
'api_key' => 'xxx',
'type' => 'hello',
'title' => 'this is title',
'body' => 'this is body',
'generator' => 'API example'
)
);
// Send the POST request (with cURL)
$c = curl_init('http://api.tumblr.com/v2/blog/abc.tumblr.com/post');
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);
but not run...
Please help me!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎没有发送任何必需的 OAuth 授权标头。这是一项有点棘手的任务,因为它要求您还从参数和 oauth 令牌创建签名,因此作为初学者,您可能需要阅读此文档:http://oauth.net/core/1.0a/
另外还有一些 OAuth PHP 库可以为您完成这部分工作:http://oauth.net/code/
It looks like you are not sending any OAuth Authorization header which is required. This is a little bit of a tricky task since it requires that you also create a signature from the parameters and oauth tokens so as a starter you might want to read this documentation: http://oauth.net/core/1.0a/
Alternatively there are some OAuth PHP libraries out there which will do that part for you: http://oauth.net/code/