Notes are written first on the impression notes, and at night when it's okay to tidy up.
PHP Public Development Note series
Date: 2014.9.1
Starting today, we are officially starting to serve as a developer of the class's public platform. Because it is the first time to do this, do not understand PHP, so while learning PHP, while finishing the public platform, as their own practiced hand study well.
After logging in to the public platform, the bottom of the left-hand ribbon is the Developer Center:
There was nothing there before the developer service was opened. When this service is enabled, the Auto-reply function that is edited on the website is canceled, and the user's interaction with the public platform is transferred to the developer's access function. Talk less, start the developer function to configure the server configuration:
I have been configured here, mainly two information: URL and Token. A link and a validation label. URL is a link to our server? (How should I describe this?) ), here I use the SAE to create the application, mainly is the figure it's free (registered to send 500 cloud beans, said to be enough for the average user), registered link: http://sae.sina.com.cn/After the registration is good, you can do bad things.
First , start configuring server information:
1. Once the SAE account has been created, we are ready to create our application (can the server be understood as an application?). This piece is really unfamiliar, rookie one, my home-console-app management-Create a new app:
After clicking Create:
The two-level domain name is the URL link that we will use at that time;
Application name-Describe these yourself to fill out;
Develop the language to choose PHP;
Application type select Web Application;
The creation process will verify the independent security password What, this is set at the time of registration, not the login with the password Oh.
2, after the creation of a good, then go to the next step, the code to pass up
First click on the app that we created and select Code management on the left side of the Ribbon:
The left-hand side of the operating area shows the following:
Click the action button, there will be two action options: upload code-delete. Choose Upload Code, you can. At this point, the server is this one, and then we need to sort out the code we want to upload.
Second, PHP code
The simplest of course is to download the sample code provided in the developer Documentation: Http://mp.weixin.qq.com/mpres/htmledition/res/wx_sample.20140819.zip this link is downloaded directly.
Code Start section:
Define ("token", "Weixin") here there is the token that we need to fill out when we configure the developer service, set it up here and fill in the configuration correctly. Since we start the developer service, we first need to verify, so the execution of the code at the beginning is:
$WECHATOBJ = new Wechatcallbackapitest ();
$WECHATOBJ->valid ();
Can be seen in the sample code, the valid function is the detection of the work, after the detection of this is not necessary, to change the corresponding reply information, so after we successfully verify that the Developer service function, this code needs to be modified to:
$WECHATOBJ->responsemsg ();
This function corresponds to the action of performing a response reply.
Jump to the RESPONSEMSG function, PHP syntax can not understand, but the function is relatively simple, it is possible to get a general look:
This paragraph saw welcome to the WeChat world is almost in response to the user input message Bar, see msgtype = "text", meaning should be sent by the user is the text message type, and then return is this section of the Welcome language. If you change it, you can use this PHP file to upload to the SAE application we created, and then check the effect.
I also have a question here: I rename this php file to xxx.php, Then compressed into the Xxx.zip package, the implementation of the above mentioned upload code operation, set up the developer's URL and token, prompted that the server did not respond to the operation, tried several times have no effect, then I click on the editing code:
Found in the file in addition to my xxx.php file, there is a index.php, and then online to find a similar information is said ZIP package to be named Index.zip, and then our PHP file needs to be named index.php, so that can be. It was a successful change, but why did you do it?
After setting up, detection--Send a text message to the public number, will return the returned information we set up. At this point, the opening of the developer service is successful, after the further toss began.