WeChat public platform development tutorial-PHP development

Source: Internet
Author: User
To develop a public platform, you must first become a developer. You can register an account at mp.weixin.qq.com and enter the relevant information as required. To develop a public platform, you must first become a developer. You can register an account at https://mp.weixin.qq.com/and then enter the relevant information as required.

With the public account, select the Development Mode in the advanced functions of the public platform, and enter the URL and Token options in the server configuration. The Token can be defined as needed, it is generally a combination of English letters and numbers, but it is a little difficult for the URL, it is best to have your own host or virtual space, it is best to register a free space on Sina.

In terms of technology, I hate theoretical things most. I like instance operations. I believe many people do the same. Now I will write down my operation process.

The following figure shows my operation records. If the above requirements are met, follow these steps.

1. Download the official example file from the public network.

To http://mp.weixin.qq.com/wiki/index.php? Title = access guide ", find and download the PHP example code,


2. Get URL

Decompress the downloaded file and get wx_sample.php. Here I rename it to wx. php, then I create a folder api in the root directory of my space, and then put wx. upload the PHP file to the directory api, so that I can get it. My URL is http://w3note.com/api/wx.php, and tokeni will name it w3notebar.

3. Modify the sample file

In the previous step, we already have the URL and Token. before entering the server configuration in the public platform development mode, we should first upload the previously uploaded wx. open the PHP file and find "define (" TOKEN "," weixin ");". Here I replace weixin with my Token name w3note, save it, upload and overwrite it,

4. Fill in the server configuration

Fill in the obtained URL and Token information in the server configuration in the development mode of the public platform, and submit the information. After the submission is successful, a prompt will be displayed, "you have become a developer ",,


Now, I have become a developer. This is the beginning of public platform development! Maybe we still don't know what we can do as developers. Next I will do an experiment and count it as a "scanner.

Open wx. php, write a statement, and call the receiver method, such as the red box,


Locate row 49th and assign the value to $ contentStr as "hello world! ",


Next, use the number to communicate with the public number.

First, I used my mobile phone to scan the following figure, and then followed the public account w3note.

For the convenience of testing, I log on to the web version (with a mobile phone can also be), https://web.weixin.qq.com/

I sent a smiling face to the public account w3note, And then it automatically replied,


The output "hello world! ", Which is the value of the $ contentStr variable in the previous code.

Another

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.