Home > php教程 > php手册 > body text

微信JSSDK页面授权实现类

WBOY
Release: 2016-06-07 11:34:52
Original
1648 people have browsed it

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

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!