Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. <?php
  2.  
  3. //https://www.googleapis.com/books/v1/volumes?q=isbn:9781556437307&key=AIzaSyCMu2zVxIRw_ZymRBzXgCNwKaDdon2odJs
  4. $isbn = $_POST['searchcode'];
  5. $page = file_get_contents("https://www.googleapis.com/books/v1/volumes?q=isbn:".$isbn."&key=AIzaSyBsLWA8E91VrYijoWqsbeBA6L3h16Ce_i8");
  6. echo $page;
  7. $data = json_decode($page, true);
  8.  
  9. if ((@implode(",", $data['items'][0]['volumeInfo']['authors']) == NULL) && ($data['items'][0]['volumeInfo']['title'] == NULL) && ($data['items'][0]['volumeInfo']['publisher']) == NULL){
  10. echo ";N/A;N/A;N/A";
  11. }
  12.  
  13. else {
  14. if ($data['items'][0]['volumeInfo']['title'] == NULL){
  15. $title = 'N/A';
  16. } else {
  17. $title = $data['items'][0]['volumeInfo']['title'];
  18. }
  19. if (@implode(",", $data['items'][0]['volumeInfo']['authors']) == NULL){
  20. $author = $data['items'][0]['volumeInfo']['publisher'];
  21. } else {
  22. $author = @implode(",", $data['items'][0]['volumeInfo']['authors']);
  23. }
  24. if ($data['items'][0]['volumeInfo']['publisher'] == NULL){
  25. $publisher = 'N/A';
  26. } else {
  27. $publisher = $data['items'][0]['volumeInfo']['publisher'];
  28. }
  29. if ($data['items'][0]['volumeInfo']['categories'] == NULL){
  30. $category = 'N/A';
  31. } else {
  32. $category = $data['items'][0]['volumeInfo']['categories'][0];
  33. }
  34.  
  35. echo ";".$title.";".$author.";".$publisher.";".$category;
  36.  
  37. }
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement