
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
话不多少直接上源码
- switch ($RX_TYPE)
- {
- case "event":
- if (stristr($postObj->Event, "subscribe")){
- $result = $this->receiveEvent($postObj); //本地处理关注内容
- }else{
- $result = <font color="Red">$this->relayPart3("http://第三方网址/1444699637631060", $postStr,"xxx第三方秘钥xxx");</font> <font color="Red">// 除关注事件其他全部交由第三方平台</font>
- }
- break;
- case "text":
- if (strstr($postObj->Content, "498453569")){
-
- $result = $this->receiveText($postObj);
- }else{
- $result = $this-><font color="Red">relayPart3("http://第三方网址/1444699637631060", $postStr,"xxx第三方秘钥xxx");</font> <font color="Red">// 除特定关键词外文本回复全部交由第三方处理</font>
- }
- break;
- case "image":
- $result = $this->receiveImage($postObj);
- break;
- case "location":
- $result = $this-><font color="Red">relayPart3("http://第三方网址/1444699637631060", $postStr,"xxx第三方秘钥xxx");</font> <font color="Red">//位置消息全部交由第三方处理</font>
- break;
- case "voice":
- $result = $this->receiveVoice($postObj);
- break;
- case "video":
- $result = $this->receiveVideo($postObj);
- break;
- case "link":
- $result = $this->receiveLink($postObj);
- break;
- default:
- $result = "unknown msg type: ".$RX_TYPE;
- break;
- }
复制代码
可以依据上面的代码也可以整合多个第三方平台 譬如:文本处理用一个平台,自定义菜单用一个平台,位置信息用一个平台
- //回复第三方接口消息
- private function relayPart3($url, $rawData, $token3)
- {
- $headers = array("Content-Type: text/xml; charset=utf-8");
- parse_str($_SERVER['QUERY_STRING'], $Part3);
- //$token3 = "9eaaccf53326b2e515e1";
- $tmpArr3 = array($token3, $Part3['timestamp'], $Part3['nonce']);
- sort($tmpArr3, SORT_STRING);
- $tmpStr3 = implode($tmpArr3);
- $tmpStr3 = sha1($tmpStr3);
- $url = $url."?timestamp=".$Part3['timestamp']."&nonce=".$Part3[nonce]."&signature=".$tmpStr3;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $rawData);
- $output = curl_exec($ch);
- curl_close($ch);
- return $output;
- }
复制代码
|
|
|
|
|
|