Possible Duplicate:
Get contacts using Yahoo Contacts APIYahoo!에서 연락처를 가져 오는 Oauth HMAC-SHA1 인증 연락처 API
사용자로부터 Yahoo 연락처를 얻기 위해 sysyem을 개발 중입니다. http://developer.yahoo.com/oauth/guide/oauth-auth-flow.html에서 모든 단계를 완료했으며 이미 액세스 토큰 및 토큰 비밀을 가지고 있습니다. 내가 HMAC-SHA1 알고리즘을 사용하여 서명하는 데 문제가
, 나는 키 서명 생성 http://developer.yahoo.com/oauth/guide/oauth-signing.html의 단계를 따라했습니다하지만 특정 사용자의 연락처를 요청할 때 오류 얻을 : 다음은
<yahoo:error xmlns: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>
을 서명 키를 생성하는 코드 :
$s = 'oauth_consumer_key='.rawurlencode($yahoo_consumer_key).'&';
$s .= 'oauth_nonce='.rawurlencode(uniqid()).'&';
$s .= 'oauth_signature_method='.rawurlencode('HMAC-SHA1').'&';
$s .= 'oauth_timestamp='.rawurlencode(time()).'&';
$s .= 'oauth_token='.rawurlencode($ouathToken).'&';
$s .= 'oauth_version='.rawurlencode('1.0').'&';
$s .= 'realm='.rawurlencode('yahooapis.com');
$baseString ='GET&'.rawurlencode('http://social.yahooapis.com/v1/user/'.$guid.'/contacts').'&'.rawurlencode($s);
$signingKey = rawurlencode($yahoo_consumer_secret).'&'.rawurlencode($ouathTokenSecret);
$signature = urlencode(base64_encode(hash_hmac('sha1', $baseString, $signingKey, true)));
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_HTTPGET => true,
CURLOPT_POST => false,
CURLOPT_URL => 'http://social.yahooapis.com/v1/user/'.$guid.'/contacts'.
'?realm=yahooapis.com'.
'&oauth_consumer_key='.$yahoo_consumer_key.
'&oauth_nonce='.uniqid().
'&oauth_signature_method=HMAC-SHA1'.
'&oauth_timestamp='.time().
'&oauth_token='.$ouathToken.
'&oauth_version=1.0'.
'&oauth_signature='.$signature
));
$result = curl_exec($ch);
누구든지 실수를 어디에서 알 수 있습니까? 서명 키를 올바르게 생성하지 않았습니까?
감사합니다.
$ baseString = 'GET &'. rawurlencode ('http://social.yahooapis.com/v1/user/'.$guid.'/contacts'). '&'. rawurlencode ($ s); ururencode로 rawurlencode를 대체해야합니까? 나는 여러 가지 방법을 시도했지만 여전히 같은 오류가 발생합니다. 더 구체적으로 할 수 있습니까? – user1519240
미안하지만, 완전히 뒤에서 얻었습니다. - 모든 것이 RFC 3986을 사용하는 rawurlencoded 여야합니다. 그러나 OAuth 문서에 따르면 RFC3986에 따라 예약 된 문자 만 인코딩 할 수 있으며 다른 모든 인코딩은 수행하지 않아야합니다. http://oauth.net/core/1.0/에서 모든 단계가 올바른지 확인하십시오. 올바른 PHP 함수로 내 대답을 편집했습니다. raw/urlencoding을 섞어서는 안되며 모든 것이 rawurlencode()를 사용하여 균일해야합니다. – Jack
또한 RFC 3986 예약 문자 목록의 일부가 아닌 인코딩 된 문자가 없는지 확인하십시오. PHP는 버전에 따라 raw/urlencoding을 사용하여 때로는 이상한 것을 수행합니다. http : // www. faqs.org/rfcs/rfc3986.html – Jack