新浪微博Error_code: 400; Error: 40022:Error: source paramter(appkey) is missing的解决方法

今天开始新浪微博,在调用statuses/public_timeline 获取最新的公共微博消息 的API出现Error_code: 400; Error: 40022:Error: source paramter(appkey) is missing的错误,终于还是解决了问题,原来是少了一条语句"source" => $consumer->key,

打开weibooauth.php文件,大约在270多行有一些代码

public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
@$parameters or $parameters = array();
$defaults = array("source" => $consumer->key,//缺少的就是这条语句,加上即可
"oauth_version" => OAuthRequest::$version,
"oauth_nonce" => OAuthRequest::generate_nonce(),
"oauth_timestamp" => OAuthRequest::generate_timestamp(),
"oauth_consumer_key" => $consumer->key);
if ($token)
$defaults['oauth_token'] = $token->key;
$parameters = array_merge($defaults, $parameters);
return new OAuthRequest($http_method, $http_url, $parameters);
}