新浪微博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) {<br /> @$parameters or $parameters = array();<br /> $defaults = array("source" => $consumer->key,//缺少的就是這條語句,加上即可<br /> "oauth_version" => OAuthRequest::$version,<br /> "oauth_nonce" => OAuthRequest::generate_nonce(),<br /> "oauth_timestamp" => OAuthRequest::generate_timestamp(),<br /> "oauth_consumer_key" => $consumer->key);<br /> if ($token)<br /> $defaults['oauth_token'] = $token->key;<br /> $parameters = array_merge($defaults, $parameters);<br /> return new OAuthRequest($http_method, $http_url, $parameters);<br /> }