我正在尝试使用OAuth 库- 它适用于 yelp 但不适用于 twitter。
这是代码:
require_once ('lib/OAuth.php');
$unsigned_url = "https://api.twitter.com/1.1/search/tweets.json?q=test";
$consumer_key = "";
$consumer_secret = "";
$token = "";
$token_secret = "";
$token = new OAuthToken($token, $token_secret);
$consumer = new OAuthConsumer($consumer_key, $consumer_secret);
$signature_method = new OAuthSignatureMethod_HMAC_SHA1();
$oauthrequest = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $unsigned_url);
$oauthrequest->sign_request($signature_method, $consumer, $token);
$signed_url = $oauthrequest->to_url();
$ch = curl_init($signed_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
print_r($data);
这是返回空白代码 - 没有任何错误。同样,仅对于 twitter,yelp 可以正常工作。非常感谢帮助,谢谢。