How to use Baidu Cloud API
There are many free APIs in Baidu Cloud. We register an account to obtain these API interfaces, but many people don’t know how to use them after buying them. Here I will introduce the usage of Baidu Cloud APIs.
Note: This article is used in the WeChat applet, and the usage methods of other languages are almost the same.
First, register an account in Baidu Cloud, which is free of charge.
Open the API store page in the cloud market.
Select an API and purchase.
Take the weather forecast API as an example:
after the purchase is completed, the order can be found in the management console of the buyer center.
Or you can see this order in the cloud market.
Click Manage.
Here is the basic information
. There is an AppCode in the basic information, and you can see it by clicking Show Secret Key.
Then write the request in the applet. Configure our AppCode
shadow part in the request header (header) is the user's own AppCode
Then click to debug in the basic information of Baidu Cloud.
The call address on this page is the interface we can call directly.
We can also enter this page to debug, the headers are written in the same way.
This is how we call Baidu Cloud API. The same is true in node. After configuring our AppCode in the header, we can request smoothly.
Don't forget to open this configuration when using http requests, otherwise an error will be reported