最近研究新浪微博api,在调用Trends/statuses接口获取话题信息的时候,一直出现40022错误,查了一下开发文档的错误列表,是source参数(appkey)缺失。这个新浪没有解释,不懂是什么意思,又在网上找了一下,原来是官方的php文档需要加一句"source" => $consumer->key,具体位置是在from_consumer_and_token函数,269行。插入的代码如下:
1 public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) { 2 @$parameters or $parameters = array(); 3 $defaults = array("oauth_version" => OAuthRequest::$version, 4 "source" => $consumer->key, //缺少的行 5 "oauth_nonce" => OAuthRequest::generate_nonce(), 6 "oauth_timestamp" => OAuthRequest::generate_timestamp(), 7 "oauth_consumer_key" => $consumer->key); 8 if ($token) 9 $defaults['oauth_token'] = $token->key;10 11 $parameters = array_merge($defaults, $parameters);12 13 return new OAuthRequest($http_method, $http_url, $parameters);14 }