diff goodreads/addToShelf.php @ 6:077b0a0a3e6d

remaining originals according to dependency walk
author Robert Boland <robert@markup.co.uk>
date Thu, 16 Feb 2017 22:29:02 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/goodreads/addToShelf.php	Thu Feb 16 22:29:02 2017 +0000
@@ -0,0 +1,37 @@
+<?php
+
+require_once('GoodreadsAPI.php');
+
+session_start();
+
+$isbn=$_GET['isbn'];
+$shelf=$_GET['shelf'];
+
+$url= "http://www.goodreads.com/book/isbn?isbn=" . $isbn . "&key=8vxmKmAn8AVolobtvBbMIg";
+
+$crl = curl_init();
+$timeout = 5;
+curl_setopt ($crl, CURLOPT_URL,$url);
+curl_setopt ($crl, CURLOPT_ENCODING , "gzip");
+curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
+curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
+$ret = curl_exec($crl);
+curl_close($crl);
+
+$ret = preg_replace("/[^[:alnum:][:punct:][:space:]]/","",$ret);
+$xml = new SimpleXMLElement($ret);
+		
+$book_id = $xml->book->id;	
+echo $book_id;
+
+$access_token = $_SESSION['access_token'];
+print_r($access_token);
+
+$obj = new GoodreadsApi(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
+
+$content = $obj->doPost('http://www.goodreads.com/shelf/add_to_shelf.xml', array("name" => "$shelf", "book_id" => "$book_id"));
+print_r($content);
+
+unset ($obj);
+
+?>