删除JSAPI授权TICKET
@param string $type TICKET类型(wx_card|jsapi)
@param string $appid 强制指定有效APPID
@return void
191907
public function delTicket($type = 'jsapi', $appid = null)
    {
        is_null($appid) && $appid = $this->config->get('appid');
        $cache_name = "{$appid}_ticket_{$type}";
        Tools::delCache($cache_name);
    }
1292549
public function setType( $type )
	{
		if ( $type == $this->getType() ) { return; }

		$this->_checkType( $type );

		$this->_values['type'] = (string) $type;
		$this->setModified();
	}
452582
public function registerEvent($type, $extra = null)
    {
        $this->context['event']['type'] = $type;
        if (!empty($extra)) {
            $this->context['event']['extra'] = $extra;
        }
    }
269867
private function setTicket($type=false,$ticket,$appId)
	{
		$name = $this->_config['ticketName'];

		if($type){
			// add client info to old ticket
			if(!array_search($appId,$ticket['clients']))
				$ticket['clients'][] = $appId;
			$ticket['check_at'] = time();
			setcookie($name,$ticket);
			$_SESSION[$name] = $ticket;
		}else{
			// new ticket
			$expire_time = (int)$ticket['expire_time'];
			setcookie($name."['id']",$ticket['id'],time()+$expire_time);
			setcookie($name."['create_at']",$ticket['create_at'],time()+$expire_time);
			setcookie($name."['expire_time']",$ticket['expire_time'],time()+$expire_time);
			setcookie($name."['check_at']",$ticket['check_at'],time()+$expire_time);
			$i = 0;
			foreach($ticket['clients'] as $client){
				setcookie($name.'[\'clients\']['.$i.']',$client,time()+$expire_time);
				$i++;
			}
			setcookie($name."['user']",$ticket['user']); //debug
			$_SESSION[$name] = $ticket;
		}
	}
77568
public function insertType(Type $type, $typeId = null)
    {
        try {
            return $this->innerGateway->insertType($type, $typeId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
379905
public function attachImagesToWidget(int $widgetID, string $widgetType): void
    {
        $widget = $this->getWidgetObject($widgetID);

        $images = (config('widgets.images.conversions.'.$widgetType)) ? array_keys(config('widgets.images.conversions.'.$widgetType)) : [];
        $this->services['images']->attachToObject(request(), $widget, $images, 'widgets', $widgetType);
    }
365322
public function apply($plugin_appid)
    {
        $url = 'https://api.weixin.qq.com/wxa/plugin?access_token=ACCESS_TOKEN';
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->callPostApi($url, ['action' => 'apply', 'plugin_appid' => $plugin_appid], true);
    }
605075
public function setByType($type)
    {
        if (isset(self::$typeList[$type])) {
            $this->value = self::$typeList[$type];
        } else {
            throw new Exception("undefined index $type");
        }
    }
199877
public function my_dispatchEvent($type, $data)
    {
        foreach ($this->client as $client) {
            $client->dispatchEvent($type, $data);
        }
    }
1319695
public function getTicket(bool $refresh = false, string $type = 'wx_card'): array
    {
        return parent::getTicket($refresh, $type);
    }
218305
public function purgeIndex($type)
    {
        $result = $this->client->request('DELETE', "/{$this->indexName}/{$type}/_query?q=id:*");
        $this->flush();

        if ($result->headers['status'] !== 200) {
            //throw new RuntimeException(
            //    "Wrong HTTP status received from Elasticsearch: " . $result->headers["status"]
            //);
        }
    }
378208
public function getJsSign($url, $appid = null, $ticket = null)
    {
        list($url,) = explode('#', $url);
        is_null($ticket) && $ticket = $this->getTicket('jsapi');
        is_null($appid) && $appid = $this->config->get('appid');
        $data = ["url" => $url, "timestamp" => '' . time(), "jsapi_ticket" => $ticket, "noncestr" => Tools::createNoncestr(16)];
        return [
            'debug'     => false,
            "appId"     => $appid,
            "nonceStr"  => $data['noncestr'],
            "timestamp" => $data['timestamp'],
            "signature" => $this->getSignature($data, 'sha1'),
            'jsApiList' => [
                'updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone',
                'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'onVoicePlayEnd', 'uploadVoice', 'downloadVoice',
                'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'translateVoice', 'getNetworkType', 'openLocation', 'getLocation',
                'hideOptionMenu', 'showOptionMenu', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem',
                'closeWindow', 'scanQRCode', 'chooseWXPay', 'openProductSpecificView', 'addCard', 'chooseCard', 'openCard',
            ],
        ];
    }
100927
public function sendFile($id,$fid,$type) {
		$send_snoopy = new Snoopy; 
		$post = array();
		$post['tofakeid'] = $id;
		$post['type'] = $type;
		$post['token'] = $this->_token;
		$post['fid'] = $fid;
		$post['fileid'] = $fid;
		$post['error'] = 'false';
		$post['ajax'] = 1;
        $send_snoopy->referer = "https://mp.weixin.qq.com/cgi-bin/singlemsgpage?fromfakeid={$id}&msgid=&source=&count=20&t=wxm-singlechat&lang=zh_CN";
		$send_snoopy->rawheaders['Cookie']= $this->cookie;
		$submit = "https://mp.weixin.qq.com/cgi-bin/singlesend?t=ajax-response";
		$send_snoopy->submit($submit,$post);
		$result = $send_snoopy->results;
		$this->log('sendfile:'.$result);
		$json = json_decode($result,true);
		if ($json && $json['ret']==0) 
			return true;
		else
			return false;
	}
753517
public function resetJsTicket($appid=''){
		if (!$appid) $appid = $this->appid;
		$this->jsapi_ticket = '';
		$authname = 'qywechat_jsapi_ticket'.$appid;
		$this->removeCache($authname);
		return true;
	}
1218206
public function getTicket(bool $refresh = false, string $type = 'jsapi'): array
    {
        $cacheKey = sprintf('easywechat.basic_service.jssdk.ticket.%s.%s', $type, $this->getAppId());

        if (!$refresh && $this->getCache()->has($cacheKey)) {
            return $this->getCache()->get($cacheKey);
        }

        $result = $this->castResponseToType(
            $this->requestRaw($this->ticketEndpoint, 'GET', ['query' => ['type' => $type]]),
            'array'
        );

        $this->getCache()->set($cacheKey, $result, $result['expires_in'] - 500);

        if (!$this->getCache()->has($cacheKey)) {
            throw new RuntimeException('Failed to cache jssdk ticket.');
        }

        return $result;
    }
9049
protected function requestJsApiTicket($type = 'jsapi')
    {
        $result = $this->httpGet(self::WECHAT_JS_API_TICKET_PREFIX, [
            'access_token' => $this->getAccessToken(),
            'type' => $type
        ]);
        return isset($result['ticket']) ? $result : false;
    }
361349
public function callBack($appId, $fromClient, $to, $fromSerNum = null, $toSerNum = null, $type = 'json')
    {
        $url = self::BaseUrl . self::SoftVersion . '/Accounts/' . $this->accountSid . '/Calls/callBack?sig=' . $this->getSigParameter();
        if ($type === 'json') {
            $body_json = array('callback' => array(
                'appId'      => $appId,
                'fromClient' => $fromClient,
                'fromSerNum' => $fromSerNum,
                'to'         => $to,
                'toSerNum'   => $toSerNum,
            ));
            $body = json_encode($body_json);
        } elseif ($type === 'xml') {
            $body_xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                        <callback>
                            <fromClient>' . $fromClient . '</clientNumber>
                            <fromSerNum>' . $fromSerNum . '</chargeType>
                            <to>' . $to . '</charge>
                            <toSerNum>' . $toSerNum . '</toSerNum>
                            <appId>' . $appId . '</appId>
                        </callback>';
            $body = trim($body_xml);
        } else {
            throw new Exception('只能json或xml，默认为json');
        }
        $data = $this->getResult($url, $body, $type, 'post');

        return $data;
    }