Google Image search in Php

Golden_flash picture Golden_flash · Jan 23, 2016 · Viewed 8.2k times · Source

I'm trying to use google images api with PHP, and I'm really not sure what to do.

I have written the following Code

<?php
$url = "https://ajax.googleapis.com/ajax/services/search/images?".
"v=1.0&q=indian%20institue%20of%20techology";
$jk=file_get_contents($url);
$json = json_decode($jk, true);
echo $json["responseData"]["results"][0]["url"];
?>

I wish to find the url of 1st Image from image search. I'm not getting any result when using the script.

Answer

chrki picture chrki · Jan 23, 2016

Google has retired the image search API, it is no longer available (see this SO thread with alternatives).

If you open up the URL you provided it will say this:

{"responseData": null, "responseDetails": "This API is no longer available.", "responseStatus": 403}