12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- /**
- * Created by 上海风车教育科技有限公司.
- * User: 刘红伟
- * Date: 15-11-24
- * Email: 454303753@qq.com
- * File:wechataccesstoken.php
- */
- class wechataccesstoken{
- private $appid;
- private $secret;
- private $_errorno;
- private $_error;
- public function __construct($appid,$secret)
- {
- $this->appid=$appid;
- $this->secret=$secret;
- }
- public function get(){
- $url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$this->appid."&secret=".$this->secret;
- $http= wx_http::factory($url,wx_http::TYPE_CURL);
- $json= $http->get();
- $result=json_decode($json,true);
- if(isset($result['errcode'])){
- $this->_errorno=$result['errcode'];
- $this->_error=$result['errmsg'];
- return false;
- }
- if(isset($result['access_token'])){
- return $result;
- }
- }
- public function getErrno()
- {
- return $this->_errno;
- }
- public function getError()
- {
- return $this->_error;
- }
- }
|