开发者

How do i use an API

I've never used an API and was wondering how you use them... I would like to u开发者_运维技巧se facebook, twitter and vimeo's api,

Can someone explain the basics of using them, how do i access them and use them etc.

Please and thanks Neil


How to use an API depends on the API. Usually the API creator has documentation on how to use their specific API.

Mostly, things work like the following: You register to get a developer key. Then, you send requests to the service via HTTP (for example Twitter is using REST, which requires you to send XML or JSON to a specific http-URL providing your key). You get an answer from the service, which you must then parse and react to accordingly (for example filling a list with contacts, etc.).

Most of the time this all comes down to:

  1. Create an XML or JSON document that describes the call parameters
  2. Send the document to an URL using GET, POST or other request methods
  3. Get the server's response
  4. Parse and evaluate the response

The specific ways to use the API, especially performing authentication, can be found on the service's developer pages.


The best way to start if you want to use an API is to read it's documentation, find some tutorials and code examples. This is always/usually published by the one offering an API.

Good luck :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜