我使用php curl将Google结果显示在我的页面中。它在我在查询中使用英语单词时有效,但是当我使用希腊语单词时,它不会显示任何结果。那是为什么?
$url = 'http://ajax.googleapis.com/ajax/services/search/web?rsz=large&v=1.0&hl=el&q='.$query;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']);
$body = curl_exec($ch);
curl_close($ch);
$json = new Services_JSON();
$json = $json->decode($body);
foreach($json->responseData->results as $searchresult)
{
if($searchresult->GsearchResultClass == 'GwebSearch')
{
echo '<div class="searchresult">';
echo '<a href="' . $searchresult->unescapedUrl . '" target="_blank">' . $searchresult->titleNoFormatting . '</a>';
echo $searchresult->content;
echo $searchresult->visibleUrl;
echo '</div>';
}
}