我所试图做的事:连接到通过PHP中的tumblr API v2和能够创造新职位无法使用的tumblr API V2使POST请求
问题:的API响应总是类似于Invalid OAuth credentials. Unable to get info
奇怪的部分是,我能够连接到API(http://www.tumblr.com/docs/en/api/v2)没有问题,当我做一个GET请求,但是当我尝试创建POST时,必须有一些我的签名必须做错。
这里是我的代码:
$params = array("type" => "quote", "quote"=>"test");
$consumer = new OAuthConsumer($consumer_key, $consumer_secret, null);
$token = new OAuthConsumer($access_token['oauth_token'], $consumer_secret);
$req_req = OAuthRequest::from_consumer_and_token($consumer, $token,
"POST", 'http://api.tumblr.com/v2/blog/MY_URL/post', $params);
$req_req->sign_request(new OAuthSignatureMethod_HMAC_SHA1(),
$consumer, $token, null);
$result = $req_req->to_postdata();
$ch = curl_init('http://www.tumblr.com/api/write');
curl_setopt($ch, CURLOPT_URL, 'http://www.tumblr.com/api/write');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $result);
的$result
一个var_dump
呼应以下
oauth_consumer_key=xxxxxxxx&oauth_nonce=xxxxxxx&oauth_signature=xxxxxx
&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1325033502&oauth_token=xxxxxx
&oauth_version=1.0"e=test&type=quote
我不知道该curl_init
必须调用http://www.tumblr.com/api/write
,但我也试图与api.tumblr.com/v2/blog/{base-hostname}/post
没有运气
我也检查了所有变量,看看令牌是否可以,它们似乎工作正常。
任何暗示正确的方向将不胜感激,因为我去了谷歌的第30页,我只是看到与我有同样问题的人。