douzhou7037 2014-12-11 14:55
浏览 41
已采纳

使用谷歌饲料api与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); ?> This is giving me an error : Catchable fatal error: Object of class stdClass could not be converted to string

  • 写回答

1条回答 默认 最新

  • doushanmo7024 2014-12-11 17:53
    关注

    try this:

    <?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';
    }
    ?>
    

    you have to call it by http://example.com/thisfile.php?query=my_text

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?