Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help with Google Books API

Featured Replies

I'm performing a search of the Google Books API and I'm trying to use the individual pieces of data it sends back but I'm not too sure how really...

 

Here's what I have so far...

 

isbn = $_POST['isbn'];
$url = "https://www.googleapis.com/books/v1/volumes?q=isbn:" . $isbn . "&key={API Key}";
$test1 = file_get_contents($url);

echo "<pre>";
print_r ($test1);
echo "</pre>";

 

This performs the search and returns this information

 

https://www.googleapis.com/books/v1/volumes?q=isbn:1604502428

 

but in my site.

 

How do I take the individual parts such as the name of the author? I've tried using simpleXML_load_string but I couldn't get it to work, not too sure if I was even doing it right tbh

looks like it returns JSON to me, so you need to pass it through a json parser to decode it to native array format.

 

$data = json_decode($test1);
print_r($data);

  • Author

this managed to do it

 

$obj = json_decode($test1, true);
echo $obj['items']['0']['volumeInfo']['title'];

 

thanks

  • Author

As Jock says, Print_r - solves soooo many issues in PHP when it comes to outputting data.

I knew how to view the data using print_r, I just couldn't isolate the individual parts, managed it now though

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.