Home  >  Article  >  php教程  >  微信JSSDK页面授权实现类

微信JSSDK页面授权实现类

WBOY
WBOYOriginal
2016-06-07 11:34:521628browse

微信页面授权–(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元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn