0

<?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

3
  • the json decoded data is now an object, treat it as such Commented Dec 11, 2014 at 15:00
  • 1
    extract($_GET) is very evil then you can use register globals its much easier :D and very deprecated :D Commented Dec 11, 2014 at 15:03
  • $data is an object, so you can't echo it. You can print_r it to get an idea of its structure. Commented Dec 11, 2014 at 17:55

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.