1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using APIs

Discussion in 'HTML, Graphics & Programming' started by Kemik, Nov 1, 2018.

  1. Kemik

    Mobster

    Joined: Nov 7, 2005

    Posts: 4,527

    Location: Widnes

    Hi guys,

    Does anyone have a good, beginners guide to using APIs with php?

    I need to call an API to get the data, then send it via a different API to effectively integrate two websites. I would then setup cPanel to use CURL and call the php script every night, pushing the data from one site to the other.

    Thanks!
     
  2. Spunkey

    Capodecina

    Joined: Oct 18, 2002

    Posts: 13,462

    Location: The land of milk & beans

    Assuming the third party doesn't provide an SDK to use with their API, then you appear to already have your answer; use cURL :)
     
  3. Kemik

    Mobster

    Joined: Nov 7, 2005

    Posts: 4,527

    Location: Widnes

    Curl I use in coanel though is just setting a time and enter the URL. I don't really know how to use curl. The documentation for the APi just references the URL to call and then what is returned.
     
  4. touch

    Capodecina

    Joined: Oct 28, 2006

    Posts: 10,617

    Location: Sufferlandria

    cURL is quite simple - it just gets content from a URL (whatever content type the URL returns, HTML, XML, etc)
    It's just the tool you use to communicate with the API. The API itself doesn't care what tool you use to communicate with it, it just needs the right parameters sent in the URL and it'll return the data. It's up to you to write some code to add the parameters you want in the URL then call that URL with cURL and process the response.
     
  5. kkelly

    Mobster

    Joined: Oct 8, 2003

    Posts: 2,583

    Location: Glasgow