Using Google Books API

前端 未结 2 1811
刺人心
刺人心 2021-01-07 14:36

I\'m having trouble using the Google Books API

I am inexperienced in working with JSON.

My form:

2条回答
  •  清酒与你
    2021-01-07 14:51

    Take a look at the Google Books API client library for PHP https://developers.google.com/books/docs/v1/libraries (They have some examples.) What you're trying to do is not going to work for at least two reasons:

    1. You have to authenticate to the API with your API Key.
    2. header("Location: $page"); redirects; it doesn't grab the page contents.

    Edit: The authenticating part is not true if you don't need to access or create your own "bookshelves." So you could try:

    $data = file_get_contents($page);
    $data = json_decode($data, true);
    $item = $data->items;
    

提交回复
热议问题