Development (1) application interface and token acquisition
Author: Songyang
This article is from Ashura road and is prohibited for commercial purposes. For more information, see the source.
Link: http://blog.csdn.net/fansongy/article/details/43233369
Apply for developers
Log onto the public platform and click the Developer Center on the left to apply to become a developer.
You can see the Developer Center interface, which includes AppId and AppSecret. Currently, the AppSecret is partially hidden. If you want to view the complete version, you need to bind your mobile phone and brush the QR code. This looks safe.
Get Access_token
In order not to expose the automatic AppId and AppSecret, we need to use an access_token to the server.GET
Method to access the following URL:
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET
Parameter description
Parameters |
Required? |
Description |
Grant_type |
Yes |
Obtain access_token and enter client_credentia |
Appid |
Yes |
Unique third-party user credential |
Secret |
Yes |
The unique credential key of a third-party user, that is, appsecret |
The returned result is Json:
{ "access_token": "G4TT9jG3Y3S3pK4rBMxuCHFgRdo56SQKpC8WKv_4-rIeJ0UwnOaN9t8DCoIyKgSDAVAIKdV2cveWZ--oOEvsoYGy1jBTicXWQCgq2SHdo-Y", "expires_in": 7200}
This access_token can be used by our server to request various information from the server. The relevant documentation is here
Access interface
List of server IP addresses as test requests.
Access:
https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=ACCESS_TOKEN
Replace ACCESS_TOKEN with the text requested in the previous step. We can see that a Json is returned:
{ "ip_list": [ "101.226.62.77", "101.226.62.78", "101.226.62.79", "140.207.54.77", "140.207.54.78", "140.207.54.79", "140.207.54.80" ]}
These are the server address list.
Error List
An error occurs when a network request is sent. The official Error List document is here.