Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //https://www.googleapis.com/books/v1/volumes?q=isbn:9781556437307&key=AIzaSyCMu2zVxIRw_ZymRBzXgCNwKaDdon2odJs
- $isbn = $_POST['searchcode'];
- $page = file_get_contents("https://www.googleapis.com/books/v1/volumes?q=isbn:".$isbn."&key=AIzaSyBsLWA8E91VrYijoWqsbeBA6L3h16Ce_i8");
- echo $page;
- $data = json_decode($page, true);
- if ((@implode(",", $data['items'][0]['volumeInfo']['authors']) == NULL) && ($data['items'][0]['volumeInfo']['title'] == NULL) && ($data['items'][0]['volumeInfo']['publisher']) == NULL){
- echo ";N/A;N/A;N/A";
- }
- else {
- if ($data['items'][0]['volumeInfo']['title'] == NULL){
- $title = 'N/A';
- } else {
- $title = $data['items'][0]['volumeInfo']['title'];
- }
- if (@implode(",", $data['items'][0]['volumeInfo']['authors']) == NULL){
- $author = $data['items'][0]['volumeInfo']['publisher'];
- } else {
- $author = @implode(",", $data['items'][0]['volumeInfo']['authors']);
- }
- if ($data['items'][0]['volumeInfo']['publisher'] == NULL){
- $publisher = 'N/A';
- } else {
- $publisher = $data['items'][0]['volumeInfo']['publisher'];
- }
- if ($data['items'][0]['volumeInfo']['categories'] == NULL){
- $category = 'N/A';
- } else {
- $category = $data['items'][0]['volumeInfo']['categories'][0];
- }
- echo ";".$title.";".$author.";".$publisher.";".$category;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement