我已经完成了所有oauth循环,当我拨打电话获取联系人信息时,我只收到401错误。
这是我的代码:
<?php
//define yahoo consumer key
$yahoo_consumer_key = variable_get('_contact_grabber_yahoo_consumer_key',NULL);
define('YAHOO_CONSUMER_KEY', $yahoo_consumer_key);
//define yahoo consumer_secret
$yahoo_consumer_secret = variable_get('_contact_grabber_yahoo_consumer_secret',NULL);
define('YAHOO_CONSUMER_SECRET', $yahoo_consumer_secret);
//define yahoo callback
$yahoo_callback = variable_get('_contact_grabber_yahoo_callback',NULL);
define('YAHOO_CALLBACK', $yahoo_callback);
//define app id constant
$yahoo_app_id = variable_get('_contact_grabber_yahoo_app_id',NULL);
define('YAHOO_APP_ID', $yahoo_app_id);
$url =
'http://social.yahooapis.com/v1/user/'.$_SESSION['yahoo']['token']['xoauth_yahoo_guid'].'/contacts?';
$url .= 'oauth_consumer_key='.YAHOO_CONSUMER_KEY;
$url .= '&oauth_nonce='.sha1(time() + rand(0,10));
$url .= '&oauth_signature_method=plaintext';
$url .= '&oauth_timestamp='.time();
$url .= '&oauth_token='.$_SESSION['yahoo']['token']['oauth_token'];
$url .= '&oauth_version=1.0';
$url .= '&oauth_signature='.YAHOO_CONSUMER_SECRET;
$result = drupal_http_request($url);
dpm($result);
?>
这是错误:
<yahoo:error xml:lang="en-US">
<yahoo:description>
Please provide valid credentials. OAuth oauth_problem="signature_invalid", realm="yahooapis.com"
</yahoo:description>
</yahoo:error>
我找不到如何解决这个问题。 感谢
奥斯卡
答案 0 :(得分:0)
如果其他人偶然发现这一点,你不能使用明文作为api,你的签名必须使用HMAC-SHA1签名
关于如何执行此操作的帖子很少,我会从这里开始:Oauth HMAC-SHA1 authentication to get contacts from Yahoo! Contacts API