将谷歌提要 API 与 php 一起使用


Using google feed api with php

<?php extract($_GET); $data = file_get_contents("http://ajax.googleapis.com/ajax/services/feed/find?v=1.0&q=" . $category ); echo json_decode($data); ?> 这给了我一个错误:可捕获的致命错误:类 stdClass 的对象无法转换为字符串

试试这个:

<?php
$data = file_get_contents("http://ajax.googleapis.com/ajax/services/feed/find?v=1.0&q=".$_GET["query"]);
$object = json_decode($data);
if(count($object->responseData->entries)>0){
    foreach($object->responseData->entries as $entry){
        echo '<pre>';
        print_r($entry);
        echo '</pre>';
    }
}else{
    echo 'no data';
}
?>

你必须通过 http://example.com/thisfile.php?query=my_text 来称呼它