As a programmer who loves to dig holes, he has to go with the tide in addition to his specialty

Here is a summary of the popular applets access open source interface configuration steps. Show a beginner the way

Let me outline the process:

  • 1. Take best’s open source interface as an example
  • 2. Register an applets developer account
  • 3. Find open source interfaces
  • 4. How to configure the domain name of the applet
  • 5. Request data

The image below (registration skipped)

Access to the Api

This is the easy source data ShowApi. One of the open source interface platform, these open source interface in fact, there are many platforms, aggregation data should be the first to do open source interface, wrote the weather forecast demo should know it. The process of registering and creating applications on other platforms is pretty much the same, and we need to return JSON

The parameters of some of its interfaces are as follows, just to give you a little bit of a setup, notice that it’s divided into system level and application level parameters, and we’ll get the other parameters of the system in a moment. Impatient xiaobai can point to the interface demo first look at json to get a sense of achievement and then look down

There is a hole here, because even if we don’t register the platform and create the application, we can get the JSON data we need. But… But… But when you try to pass page numbers or other parameters, some system-level parameters will also change. So in order to avoid going through all of these confusing traps again, what are system-level parameters

Showapi_sign and showapi_appid are all we need to know from this description. The other three parameters are business level, that is, some configuration parameters to make the access interface more secure when the project goes live, and the algorithm to encrypt appID and sign will be used.

Sign up for an account to create the app, and there you have it: AppID and sign

Ok, you have the interface, you have the parameters, you can copy it, put it in the browser to splice a full link to access, should not be unexpected should return a large string of JSON

But in the small program will report an error, because the small program needs to configure in the background to specify a secure domain name link to access (good, need trouble point, for us to consider a lot of unnecessary trouble)

Small program to create demo start

Take care of it, afraid small white impatient. We start by creating the app (don’t ask me what developer software to create it with). If the app is newly created with blank content, will help us check the QuickStart project, which automatically implements some lifecycle methods

We AppID just fill in our developer platform under Settings – Developer Settings. At this time, our application can access some built-in interfaces of wechat, such as obtaining user information. But when we access our own interface, we get an error. XXXX is not in the following list of valid request domain names, please refer to the documentation. That’s because the applet hasn’t configured the server’s secure domain name yet. Above, the second half of the department is to configure the server of the domain name, then look back just open the domain name of the interface, have you posted joining together visit, the episode is in front of the domain name https://route.showapi.com. Just add it. You’re the administrator, right? Add domain name here is to the administrator scan code, very secure feeling is it, because the upgrade of the small program default https:// protocol. So all you have to do is fill in route.showapi.com. Let’s go back to our compiler and see if it’s configured.

In the toolbar – Select Tools – Project details

See if the domain name information comes up that was configured in the background. If not, close the project and open it again. Check to make sure your legitimate domain name appears before you can access your interface. So far, you’ve been able to access the interface, but what about serving people? I’m a big lady.

Small program coding

Delete all the code generated automatically in its method first, and then create the json data set under Page({data:{}}), and Page number. I don’t have the logic to write pagination loads, but I’m just telling you to define pagination numbers and pass-throughs, because some of the demos on the web have their own pagination logic. Then copy in the requested data the appID and sign of the application just created in the easy source data. Then run it and see the console print the following information

I hope that answers your questions.