使用 Yahoo Contacts API 获取联系人 [英] Get contacts using Yahoo Contacts API

查看:55
本文介绍了使用 Yahoo Contacts API 获取联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照http://developer.yahoo.com/oauth/guide/oauth-auth-flow.html"这些步骤操作,我从经过身份验证的用户那里获得了 oauth 令牌和 GUID.现在我正在尝试通过 GUID 检索所有联系人,正如我在使用此网址http://social.yahooapis.com/v1/user/GUID_HERE/contacts"搜索网络并通过标题传递授权数据时看到的那样,但我只是得到了回复:

I followed these steps "http://developer.yahoo.com/oauth/guide/oauth-auth-flow.html" and I got oauth token and GUID from authenticated user. Now I am trying retrieve all contacts through GUID as I have seen on searchs for web using this url "http://social.yahooapis.com/v1/user/GUID_HERE/contacts" and passing authorization data via headers but I just get this response:

<?xml version='1.0' encoding='UTF-8'?><yahoo:errorxmlns:yahoo='http://yahooapis.com/v1/base.rng' xml:lang='en-US'><yahoo:description>Please provide valid credentials. OAuth oauth_problem="signature_invalid", realm="yahooapis.com"</yahoo:description></yahoo:error><!-- ws129.socdir.sp2.yahoo.com uncompressed/chunked Tue Aug 28 06:22:40 PDT 2012 -->

我正在使用 cURL (PHP) 执行请求,就像这里写的http://developer.yahoo.com/oauth/guide/oauth-make-request.html"(我已经检查过,我正在使用我的消费者作为 ouath_signature 的秘密):

I am performing the request using cURL (PHP) like is written here "http://developer.yahoo.com/oauth/guide/oauth-make-request.html" (I have checked and I am using my consumer secret as ouath_signature):

$header = array(
'GET http://social.yahooapis.com/v1/user/' . $guid[1] . '/contacts',
'Authorization: OAuth realm="yahooapis.com", '.
                                     'oauth_consumer_key="'.$yahoo_consumer_key.'", '.
                                     'oauth_nonce="'.uniqid().'", '.
                                     'oauth_signature_method="HMAC-SHA1", '.
                                     'oauth_timestamp="'.time().'", '.
                                     'oauth_token="'.$ouathToken[1].'", '.
                                     'oauth_version="1.0", '.
                                     'oauth_signature="'.$yahoo_consumer_secret.'"');
curl_setopt_array($ch, array(
    CURLOPT_RETURNTRANSFER => true,
              CURLOPT_FOLLOWLOCATION => TRUE,
              CURLOPT_SSL_VERIFYPEER => false,
              CURLOPT_SSL_VERIFYHOST => 0,
              //CURLOPT_HTTPGET => true,
              CURLOPT_URL => 'http://social.yahooapis.com/v1/user/' . $guid[1] . '/contacts',
              CURLOPT_HTTPHEADER => $header
    ));

有人可以帮忙吗?

推荐答案

OAuth 签名不仅仅是消费者的秘密.雅虎有一些关于如何签署请求的文档,这就是oauth_signature 字段.

The OAuth Signature isn't just the consumer secret. Yahoo has some documentation on how sign the request and that's what goes in the oauth_signature field.

这篇关于使用 Yahoo Contacts API 获取联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆