Configuration and request for WeChat public platform development, WeChat public platform

Source: Internet
Author: User

Configuration and request for public platform development, public platform

I. configuration parameters

define('WEIXIN_APPID', 'wxzzzzzzzz');define('WEIXIN_APPSECRET', 'ouewjdsaudsamkh');define('WEIXIN_TOKEN', '9973833232232');define('WEIXIN_NOTIFY_URL', 'http://xx.com/xx/xx');define('WEIXIN_MCHID', '322221121');define('WEIXIN_KEY', 'xddsdswewew');

1) ID of the public account in development

WEIXIN_APPID: Application ID

WEIXIN_APPSECRET: Application key

Go to the homepage of the public platform, click the Developer Center, and you will be able to see the two items on the configuration page, which are available by default.

2) Server Configuration

WEIXIN_TOKEN, which is the token. It is a user-defined string of 3 to 32 characters and must be an English letter or number.

The URL server address, that is, the entry address of the public account. On this page, I will perform signature verification or receive event messages. Click to view related documents.

1. Signature Verification: This address is used for signature verification when the configuration is modified.

2. Receive event messages: Refers to pushing some messages and performing specific logical operations when you are concerned.

3) Payment Configuration

Click the payment menu

WEIXIN_MCHID: Merchant ID, which can be viewed in merchant Information

Weixin_policy_url: Asynchronous callback API for payment, which can update the order status, send and push Logic

WEIXIN_KEY: To set this payment key, you must log on to the payment merchant platform. After logging on, click API security, and then download the certificate and set your own key.

Ii. Request and debugging

Php has a very convenient curl. Here we mention CURLOPT_SSL_VERIFYPEER. If this attribute is not added at the beginning, the returned data is false each time the server is requested. After simulating the request with HttpRequester of firefox, you can return the data. After searching for the information, you will find that you want to set this attribute.

CURLOPT_SSL_VERIFYPEER: checks whether the server certificate is issued by an authorized CA authorized by a regular browser.
/**
* Original POST
* @ Param $ url the url of the request
* @ Param $ raw data, which can be a string or Array
* @ Return mixed return the request Value
*/
Public function rawpost ($ url, $ raw)
{
$ Resource = curl_init ();
Curl_setopt ($ resource, CURLOPT_POST, true );
Curl_setopt ($ resource, CURLOPT_URL, $ url );
Curl_setopt ($ resource, CURLOPT_POSTFIELDS, $ raw );
Curl_setopt ($ resource, CURLOPT_RETURNTRANSFER, true );
Curl_setopt ($ resource, CURLOPT_SSL_VERIFYHOST, false );
Curl_setopt ($ resource, CURLOPT_SSL_VERIFYPEER, false );
// Curl_setopt ($ resource, CURLOPT_HTTPHEADER, array ('ct :'));
$ Data = curl_exec ($ resource );
Curl_close ($ resource );
Return $ data;
}

HttpRequester is recommended here. This plug-in can simulate various submissions such as post and get, and content type can also be selected.

Development also provides an online test interface. Click to view the public platform interface debugging tool.

Various return codes are returned during request debugging. Click to view the global return code description.

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.