wx.config参数获取

<?php
//1 获取access_token
$appid="";
$appsecret="";
$result = $this->http_get('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$appid.'&secret='.$appsecret);

$json = json_decode($result,true);

$accessToken = $json['access_token'];
private function http_get($url){
$oCurl = curl_init();
if(stripos($url,"https://")!==FALSE){
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1
}
curl_setopt($oCurl, CURLOPT_URL, $url);
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );
$sContent = curl_exec($oCurl);
$aStatus = curl_getinfo($oCurl);
curl_close($oCurl);
if(intval($aStatus["http_code"])==200){
return $sContent;
}else{
return false;
}
}
//2 获取ticket
$url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=$accessToken";
$res = json_decode ( $this->http_get ( $url ) );
$ticket = $res->ticket;

private function getSignPackage($jsapiTicket,$url,$timestamp,$nonceStr) {
// 这里参数的顺序要按照 key 值 ASCII 码升序排序
$string = "jsapi_ticket=$jsapiTicket&noncestr=$nonceStr&timestamp=$timestamp&url=$url";
$signature = sha1 ( $string );

$signPackage["appId"] = C("APPID");
$signPackage["nonceStr"] = $nonceStr;
$signPackage["timestamp"] = $timestamp;
$signPackage["url"] = $url;
$signPackage["signature"] = $signature;
$signPackage["rawString"] = $string;
return $signPackage;
}
$signPackage=getSignPackage($ticket,$url,time(),"noncestr");
var_dump($signPackage);
?>

你可能感兴趣的:(config)