I'm trying to access the json that's returned from this Google books API request using wp_remote_get but its not outputting the data. Can anyone tell me what the problem is?
$request = wp_remote_get('https://books.google.com/books?bibkeys=9780001955073%2C%209780001982116%2C%209780001981768&jscmd=viewapi&callback=listisbns');
$body = wp_remote_retrieve_body( $request );
$data = json_decode( $body );
foreach( $data as $book ) {
echo $book->info_url;
}
It would be ok if you were using JavaScript via the callback function
listisbns
, to use the returned result in PHP you gotta clean up the returned string: