You can create an API using the Slim Framework. To use a different API, you can use PHP Curl.
So for example:
<?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://website.com/method"); curl_setopt($ch, CURLOPT_HEADER, 0); // No header in the result curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return, do not echo result // Fetch and return content, save it. $raw_data = curl_exec($ch); curl_close($ch); // If the API is JSON, use json_decode. $data = json_decode($raw_data); var_dump($data); ?>
source share