Calling an API in PHP

Posted by

CODE

<?php
$ch=curl_init();
$url="http://google.com/complete/search?client=firefox&q=shiv";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$resp = curl_exec($ch);
if($e =curl_error($ch))
{
echo $e;
}
else
{
$decoded = json_decode($resp);
print_r($decoded);
}
curl_close($ch);
?>
view raw get.php hosted with ❤ by GitHub

OUTPUT

guest


0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x