...
|
...
|
@@ -554,20 +554,28 @@ class LoginController extends HomeBaseController |
|
|
return $str;
|
|
|
}
|
|
|
|
|
|
//获取微信分享签名
|
|
|
public function getSignature(){
|
|
|
//获取access_token
|
|
|
public function getWxAccessToken(){
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$this->appkey2.'&secret='.$this->appsecret2;
|
|
|
$res = $this->http_get($url);
|
|
|
$json_arr = json_decode($res,true);
|
|
|
if(isset($json_arr['errcode'])&&!empty($json_arr['errcode'])){
|
|
|
//用户取消登录
|
|
|
$this->apiResponse(0, '获取配置失败');
|
|
|
}
|
|
|
$token = $json_arr['access_token'];
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token='.$token.'&type=jsapi';
|
|
|
$res = $this->http_get($url);
|
|
|
$json_arr = json_decode($res,true);
|
|
|
$ticket = $json_arr['ticket'];
|
|
|
return $token;
|
|
|
}
|
|
|
|
|
|
//获取微信分享签名
|
|
|
public function getSignature(){
|
|
|
if($_SESSION['ticket_expire_time'] > time() && $_SESSION['ticket']){
|
|
|
$ticket = $_SESSION['ticket'];
|
|
|
}else{
|
|
|
$token = $this->getWxAccessToken();
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token='.$token.'&type=jsapi';
|
|
|
$res = $this->http_get($url);
|
|
|
$json_arr = json_decode($res,true);
|
|
|
$ticket = $json_arr['ticket'];
|
|
|
$_SESSION['ticket'] = $ticket;
|
|
|
$_SESSION['ticket_expire_time'] = time()+7000;
|
|
|
}
|
|
|
return $ticket;
|
|
|
}
|
|
|
|
...
|
...
|
|