0

I can obtain information form google books in PHP using the following code

 $page1 = file_get_contents("https://www.googleapis.com/books/v1/volumes?q=isbn:1933372826")
 $data = json_decode($page1, true);

I have an array of 1,200+ ISBNs so I want to be able to get this files so I can read it

So for example if I get each element of the array that is ISBN to be $book_isbn I tried the following but I get an error

 $page2 = file_get_contents("https://www.googleapis.com/books/v1/volumes?q=isbn:$book_isbn")
 $book_data = json_decode($page2, true);

What should I change? Can I have $book_isbn in the file_get_contents?

This is the error I get

 Parse error: syntax error, unexpected '$book_data' (T_VARIABLE)
4

1 回答 1

1

您可以使用

$book_isbn = '1933372826';
$page2 = file_get_contents("https://www.googleapis.com/books/v1/volumes?q=isbn:$book_isbn");
$book_data = json_decode($page2, true);
echo '<pre>';print_r($book_data);

如果您有多个 book_isbn 值,则使用foreach并迭代每个元素。

于 2015-09-22T03:53:26.300 回答