How to implement a basic responder

Implementing a responder for your WeChat Sandbox or Official Account is as easy as section 1,2,3!

Prerequisites:
Sandbox or Official Account,
Web server,
Database server

DownloadWeChat Basic Responder

Setup a web & database server

Create your web and database servers as you usually do. This responder just needs php and the php-mysqli extension enabled.

The responder was built on Apache with MySQL, but will also work on IIS and MSSQL with only a few quick modifications to the source code.

Deploy the basic responder code

Extract the downloaded zip file into your web server’s document root.

Import the wechat.sql file into your database.

Edit the included config.php as follows:
– Replace $token with a random text string (this is used by the WeChat admin platform to verify connectivity to your server, so be sure to also add it on your Sandbox or Official Account Developer-mode settings)
– Enter your database access details into the $db array
– Change the $appId and $appSecret variables to the ones provided by your Sandbox or Official Account Developer-mode settings)

Enter the url of your shiny new responder (responder.php) into the Sandbox or Official Account Developer-mode settings and click submit.
The system would respond with a success message if the token matches and the page is accessible over the internet.

Profit

That’s it. Your account is now ready to accept messages from WeChat and respond in kind.

The downloaded code would automatically write debug information to a file called errlog.txt
The xml_logs database table would also log a new row for each message/response that goes through your Sandbox or Official Account.

Access the admin.php page from your web browser to see the messages sent to your account and respond to them with a Push message. The menu can also be uploaded to your account from this page.