#代码如下 不知是哪里问题 测试好多天了 一直提示签名错误
private function getAccessToken(){
$key = self::[i]CLIENT_ID[/i];
$secret = self::[i]CLIENT_SECRET[/i];
$url = self::[i]URL[/i];
$time = $this->getMillisecond();
$nonce = $this->createNonceStr();
$version = "1.1";
$key = [i]rawurlencode[/i]($key);
$nonce = [i]rawurlencode[/i]($nonce);
$data = array();
$data[] = $version;
$data[] = $key;
$data[] = $secret;
$data[] = $time;
$data[] = $nonce;
[i]sort[/i]( $data );
$str = [i]implode[/i]( $data );
$sign = [i]rawurlencode[/i]([i]sha1[/i]( $str ));
$header = array();
$header[] = "authorization:OpenAuth2 version=\"1.1\", appid=\"{$key}\", timestamp={$time}, nonce=\"{$nonce}\", sign=\"{$sign}\"";
$header[] = "Content-type: application/x-www-form-urlencoded;charset=UTF-8";
$header[] = "Connection: keep-alive";
$result = $this->https_request($url,"",$header);
if(isset($result['data']['access_token'])){
return $result['data']['access_token'];
}else{
return '';
}
}
推荐阅读