Tutorial Four: Debug public server, debug public _php Tutorial

Source: Internet
Author: User

Tutorial Four: Debug public server, debug public


Before entering the formal development, we also need to master the public number development debugging methods.


If we rely entirely on the received message for debugging, we will be subject to a lot of restrictions,
For example, we can only return messages in the specified format to see what we reply to in the app.
If our server is wrong, we will not be able to know the exact error message,
So we need a tool that can replace the server to send a message to our public server and display any message formats that we have returned.


Fortunately we can find such a tool on the internet ' webbot-cli ',
The address of this tool is open source, the source address is: https://github.com/node-webot/webot-cli/blob/master/README.md


This is a tool written by Nodejs, to install this tool we first need to install the NODEJS development environment.
Here is Nodejs's official website https://nodejs.org/, according to the official website instruction Step by step installs is OK.


After the installation is complete, we can install this simulation development debugging tool with the ' NPM ' tool.
The installation commands are:

Copy Code


Installing this tool requires Administrator privileges, so Mac and Linux users may need to use ' sudo '.


After the installation is complete, we introduce the use of this tool.
We'll start running the tool directly at the command line by invoking the following command.

Copy Code


Where ' Weixin ' is the token parameter we previously configured,
' Http://weixinshow001.sinaapp.com ' is the server address for our public platform.
You need to change these two parameters to your own.


The running interface of the program looks like this:

The URL and token you just passed in will be echoed when the run succeeds.
Here we simply test a text message,
A carriage return will enter the text input interface when checked.

We randomly enter some text and then click Enter to send.
And then we see a mistake, and that's why?

The reason for this is that the tool is not sent exactly in the official message format,
The official server did not add the ' echostr ' item in the Get field when sending the message.
This tool will send the ' echostr ' field in any message.


The wechat-php library we used earlier is using this field to determine whether token authentication is a special request,
If it is token validation, the special request returns the Echostr field and terminates the subsequent operation.
This caused the error to occur.


Now let's revise our libraries authoring to be compatible with this test library.


We open the ' wechat.php ' file and find the ' isvalidateincomingconn ' function in the file,
This function is used to determine whether this request is a token authentication request.
Let's change to the following:

Copy Code


After completing the higher upload to the SAE server to make it effective, and then re-sending the text message in ' Webot ', we can see the correct echo.

Based on this type of debugging, we can even debug on the local server!
Based on this type of debugging, we can even debug on the local server!
Based on this type of debugging, we can even debug on the local server!

Just set the URL parameter of the Debug tool to the cost URL to OK.

In addition, if you like to write code on the external Web server, the official test page is also good: http://mp.weixin.qq.com/debug

Thank you for reading, please feel the heart! Hope can help the beginner of you!! Sharing is also a pleasure!!! Please relay ...

http://www.bkjia.com/PHPjc/1130486.html www.bkjia.com true http://www.bkjia.com/PHPjc/1130486.html techarticle Tutorial Four: Commissioning the public number server, commissioning the public before entering the formal development, we also need to master the public number development debugging methods. If we are completely dependent on the received message ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.