Skip to content

Instantly share code, notes, and snippets.

@v1shwa
Created October 3, 2015 04:31
Show Gist options
  • Save v1shwa/3229c4aac65551eec605 to your computer and use it in GitHub Desktop.
Save v1shwa/3229c4aac65551eec605 to your computer and use it in GitHub Desktop.
Easiest Way to use Mashape API using PHP
<?php
// Config //
// URL
$url = "https://playstore-v1.p.mashape.com/app/details?appid=com.whatsapp&lang=en";
// request timeout in seconds
$timeout = 10;
// Custom headers. X-Mashape-Key is mandatory, you can add more if you want
$headers = array(
"X-Mashape-Key: zLqjY8Vh5smshYxxxxxxxxxxxxxxxxxxxxtjsnxiwdKfOmYs9g",
"Accept: application/json"
);
// Request Type: GET | POST | PUT | PATCH | DELETE
$method = 'GET';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
echo $data;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment