本文整理匯總了PHP中Wechat::resetAuth方法的典型用法代碼示例。如果您正苦於以下問題:PHP Wechat::resetAuth方法的具體用法?PHP Wechat::resetAuth怎麽用?PHP Wechat::resetAuth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Wechat
的用法示例。
在下文中一共展示了Wechat::resetAuth方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getJsSign
function getJsSign()
{
if ($this->request->is('post')) {
$url = $this->request->data('url');
$timestamp = $this->request->data('timestamp');
$nonceStr = $this->request->data('nonceStr');
$appId = 'yourappid';
$wxObj = new Wechat(array('token' => 'yourtoken', 'appid' => $appId, 'appsecret' => 'yourpants'));
//調用對應的函數
$sign = $wxObj->getJsSign($url, $timestamp, $nonceStr);
//如果token失效,清除token重試一次
if ($wxObj->errCode == 40001 || $wxObj->errCode == 42001) {
$wxObj->resetAuth();
$sign = $wxObj->getJsSign();
}
//如果返回false,獲取errcode和errmsg
if (!$sign) {
return $this->sentJson(array('errCode' => $wxObj->errCode, 'errMsg' => WechatErrCode::getErrText($wxObj->errCode)));
}
$package = array('signature' => $sign, 'nonceStr' => $nonceStr, 'appId' => $appId, 'timestamp' => $timestamp);
return $this->sentJson(array('errCode' => 0, 'errMsg' => '', 'result' => $package));
}
}