2016-01-23 127 views
0

我想用PHP的谷歌图像API,我真的不知道该怎么办。谷歌图片搜索Php

我写了下面的代码

<?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"]; 
?> 

我希望能够找到第一个图像从图像搜索的网址。 使用脚本时我没有收到任何结果。

+0

在你的代码的第二行和第三行似乎被切断或损坏 – chrki

+0

对不起应对错误 –

回答

2

Google已经停用了图片搜索API,因此不再可用(see this SO thread with alternatives)。

如果你打开你所提供的网址,却这样说:

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

是否有替代供通过PHP脚本搜索图像? –

+0

我链接到另一个列出了一些替代品的Stackoverflow问题 – chrki