亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home WeChat Applet WeChat Development WeChat public platform message interface development and enable interface

WeChat public platform message interface development and enable interface

Feb 21, 2017 pm 04:30 PM
Micro-channel public platform

In this WeChat public platform development tutorial, we assume that you already have the basics of PHP language program, MySQL database, computer network communication, and HTTP/XML/CSS/JS.

We will use the WeChat public account Fangbei Studio as an example to explain. See the QR code at the bottom.

This series of tutorials will guide you to complete the following tasks:

  1. Apply for Baidu Cloud Platform resources

  2. Enable WeChat public platform development Mode


##First article applying for server resources

Create Baidu Cloud Application

Apply for an account

Log in to http://developer .baidu.com/bae, use your email or mobile phone to register an account. Registration requires binding your mobile phone and verifying your email.

Create application

After successful registration and login, click

on the upper right side, and the following window will pop up. 微信公眾平臺消息接口開發(fā) 啟用接口

微信公眾平臺消息接口開發(fā) 啟用接口

Fill in any application name, select "Mobile Web Application" as the access method, and then click OK.


說明:在以下的教程中,您可以將所有我填寫為pondbay的地方改為你的一個相應(yīng)的名稱,如果您沒有想好名稱,最簡單的方法就是qq這兩個字符+qq號碼,比如方倍工作室的QQ是1354386063,那么就將"pondbay"改為"qq1354386063"


微信公眾平臺消息接口開發(fā) 啟用接口

Select "Cloud Environment (BAE)",

微信公眾平臺消息接口開發(fā) 啟用接口

In the new window, fill in the name of the application domain name, select PHP as the environment type, select others according to your own needs or use the default values ????as shown above, and then click OK

注意:此處填寫的域名將要在下面填寫URL時用到??梢韵缺4嫦聛?。

Original text: http://ipnx.cn/

Create version

微信公眾平臺消息接口開發(fā) 啟用接口

In version management , click to create a new version

微信公眾平臺消息接口開發(fā) 啟用接口

#Fill in 0 for the version number, and then save.

Original text: http://ipnx.cn/

Upload code

Change the token in the following code Change it to your name and save as index.php.

注意:此處填寫的Token將要在下面填寫URL時用到??梢韵缺4嫦聛?。


<?php/*
    CopyRight 2013 www.doucube.com  All Rights Reserved*/define("TOKEN", "pondbay");$wechatObj = new wechatCallbackapiTest();if (isset($_GET[&#39;echostr&#39;])) {    $wechatObj->valid();
}else{????$wechatObj->responseMsg();
}class?wechatCallbackapiTest
{????public?function?valid()
????{????????$echoStr?=?$_GET["echostr"];????????if($this->checkSignature()){????????????echo?$echoStr;????????????exit;
????????}
????}????private?function?checkSignature()
????{????????$signature?=?$_GET["signature"];????????$timestamp?=?$_GET["timestamp"];????????$nonce?=?$_GET["nonce"];????????$token?=?TOKEN;????????$tmpArr?=?array($token,?$timestamp,?$nonce);????????sort($tmpArr);????????$tmpStr?=?implode(?$tmpArr?);????????$tmpStr?=?sha1(?$tmpStr?);????????if(?$tmpStr?==?$signature?){????????????return?true;
????????}else{????????????return?false;
????????}
????}????public?function?responseMsg()
????{????????$postStr?=?$GLOBALS["HTTP_RAW_POST_DATA"];????????if?(!empty($postStr)){????????????$postObj?=?simplexml_load_string($postStr,?'SimpleXMLElement',?LIBXML_NOCDATA);????????????$fromUsername?=?$postObj->FromUserName;????????????$toUsername?=?$postObj->ToUserName;????????????$keyword?=?trim($postObj->Content);????????????$time?=?time();????????????$textTpl?=?"<xml>
????????????????????????<ToUserName><![CDATA[%s]]></ToUserName>
????????????????????????<FromUserName><![CDATA[%s]]></FromUserName>
????????????????????????<CreateTime>%s</CreateTime>
????????????????????????<MsgType><![CDATA[%s]]></MsgType>
????????????????????????<Content><![CDATA[%s]]></Content>
????????????????????????<FuncFlag>0</FuncFlag>
????????????????????????</xml>";????????????if($keyword?==?"?"?||?$keyword?==?"?")
????????????{????????????????$msgType?=?"text";????????????????$contentStr?=?date("Y-m-d?H:i:s",time());????????????????$resultStr?=?sprintf($textTpl,?$fromUsername,?$toUsername,?$time,?$msgType,?$contentStr);????????????????echo?$resultStr;
????????????}
????????}else{????????????echo?"";????????????exit;
????????}
????}
}?>


Then compress it into ZIP format, RAR format cannot be used

微信公眾平臺消息接口開發(fā) 啟用接口

This will generate an index.zip file.

Back to version management

微信公眾平臺消息接口開發(fā) 啟用接口

Select the package to upload and update

微信公眾平臺消息接口開發(fā) 啟用接口

Select the zip you just compressed package, click Upload.

微信公眾平臺消息接口開發(fā) 啟用接口

Confirm it takes effect, and click

, as shown below. 微信公眾平臺消息接口開發(fā) 啟用接口

微信公眾平臺消息接口開發(fā) 啟用接口

百度云應(yīng)用的創(chuàng)建就成功了。

?

第二篇 啟用開發(fā)模式

微信公眾平臺開發(fā)模式

高級功能

微信公眾平臺地址:https://mp.weixin.qq.com?

登錄微信公眾平臺后臺,選擇高級功能,進(jìn)入后就看到兩種模式

微信公眾平臺消息接口開發(fā) 啟用接口

我們需要先關(guān)閉編輯模式。點擊編輯模式的進(jìn)入

微信公眾平臺消息接口開發(fā) 啟用接口

滑動關(guān)閉

微信公眾平臺消息接口開發(fā) 啟用接口

?

開發(fā)模式

進(jìn)入開發(fā)模式里面

微信公眾平臺消息接口開發(fā) 啟用接口

?點擊成為開發(fā)者

微信公眾平臺消息接口開發(fā) 啟用接口

彈出URL和Token填寫框

微信公眾平臺消息接口開發(fā) 啟用接口

此處的URL為創(chuàng)建百度云應(yīng)用的域名,包括后面的duapp.com,而Token為index.php中定義的值。在這篇教程中如下:


URL:?????http://pondbay.duapp.com
Token:??pondbay


填寫如下圖,

微信公眾平臺消息接口開發(fā) 啟用接口

?提交成功

微信公眾平臺消息接口開發(fā) 啟用接口

再滑動右上角啟用按鈕。

微信公眾平臺消息接口開發(fā) 啟用接口

恭喜,你成功啟用開發(fā)模式。

?

自動回復(fù)

在上面的例子中,實現(xiàn)了一個發(fā)送“?”就能回復(fù)當(dāng)前時間的功能。
效果如下:

微信公眾平臺消息接口開發(fā) 啟用接口

至此,你的微信公眾平臺賬號已經(jīng)實現(xiàn)自動回復(fù)了。

更多微信公眾平臺消息接口開發(fā) 啟用接口?相關(guān)文章請關(guān)注PHP中文網(wǎng)!


?

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72