微信页面授权–(JS-SDK使用权限签名算法)
使用方法:实例化此类,然后调用其中的getSignPackage()方法即可。
注意:其中涉及获取access_token和jsapi_ticket需要自己缓存,不能频繁获取!private function getAccessToken(){<br>
$appId = $this->appId;<br>
$appSecret = $this->appSecret;<br>
$url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$appId.'&secret='.$appSecret;<br>
$res = $this->api_request($url);<br>
if(isset($res->access_token)){<br>
return array(<br>
'errcode' =>0,<br>
'errmsg' =>'success',<br>
'access_token' =>$res->access_token,<br>
'expires_in' =>$res->expires_in<br>
);<br>
}else{<br>
return array(<br>
'errcode' =>$res->errcode,<br>
'errmsg' =>$res->errmsg,<br>
'access_token' =>null,<br>
'expires_in' =>null<br>
);<br>
}<br>
}
JSSDK.zip ( 3.1 KB 下载:26 次 )
AD:真正免费,域名+虚机+企业邮箱=0元