# Wechat_sdk **Repository Path**: fagework/Wechat_sdk ## Basic Information - **Project Name**: Wechat_sdk - **Description**: 微信SDK,持续更新... - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2015-11-17 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### 微信SDK ``` require(../sdk/Wechat); require(../sdk/Weather); require(../sdk/Express); private $token; protected $wechat; protected $data; function _initialize(){ $this->token = I('get.token','','htmlspecialchars'); if(!preg_match("/^[0-9a-zA-Z]{3,42}$/",$this->token)){ exit('error token'); } $configs = array( 'token' => $this->token, 'appid' => $this->wxuser['appid'], 'secret' => $this->wxuser['appsecret'] ); $this->wechat = new Wechat($configs); // 验证微信推送的签名 //$this->wechat->valid(); $this->data = $this->wechat->request(); } ``` **天气预报** ``` $tianqi = mb_substr($key,-2,2,"UTF-8"); $cityName = mb_substr($key,0,-2,"UTF-8"); if($tianqi == '天气' && !empty($cityName)){ $weather = new Weather($cityName)->find(); $this->wechat->response($weather); //引用sdk/Wechat.php } ``` **人工客服** ``` if ($key == "投诉" || $key == "人工客服"){ $this->wechat->sendMsg($data['fromusername'],'客服正在接入中...'); $this->wechat->transfer_service(); } ``` **快递查询** ``` if (preg_match("/[\x{4e00}-\x{9fa5}]{2,4}\s{0,}\w{8,15}/u",$key) || preg_match("/[A-Za-z]{3,9}\s{0,}\w{8,15}/u",$key)){ $express = new Express()->getExpressInfo($key); $this->wechat->response($express); } ``` **微信分享** ``` share.html ```