Mercurial > hg > ywww
diff goodreads/getGoodreadsShelves2.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 | 385ddd7c4b55 a67bf725e87b |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/goodreads/getGoodreadsShelves2.php Thu Feb 16 22:29:02 2017 +0000 @@ -0,0 +1,101 @@ +<?php +include "UTFUtil.php"; + +$userID=$_GET['userID']; +$grID=$_GET['grID']; +if( $userID == "" || $grID == "") +{ + echo "<html> + <link rel=\"stylesheet\" type=\"text/css\" href=\"../user/style.css\"> + <head> + <title>YourNextRead Export Unsuccessful</title> + </head> + <body> + + <h1>YourNextRead</h1> + <p>Whoops, there seems to be a problem exporting your lists. Please try again later or <a href=\"mailto:feedback@yournextread.com\">email us</a> and we will investigate!</p> + <p>Click <a href=\"http://www.yournextread.com\">here</a> to go back to YourNextRead</p> + + <p>www.YourNextRead.com</p> + + </body> + </html>"; +} +else +{ + + require_once('GoodreadsAPI.php'); + session_start(); + $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']); + $ret = $obj->doGet('http://www.goodreads.com/review/list.xml?v=2', array("id" => "$grID")); + //print_r($content); + +//$url= "http://www.goodreads.com/shelf/list?format=xml&key=8vxmKmAn8AVolobtvBbMIg&user_id=" . $grID; +//echo $url; + + /*$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); */ + $ret = preg_replace("/[^[:alnum:][:punct:][:space:]]/","",$ret); + echo $ret; + + include "../../private/db.php"; + + $xml = new SimpleXMLElement(convert_utf8($ret)); + for($i=0;$i<sizeof($xml->shelves->user_shelf);$i++){ + + $shelfName= $xml->shelves->user_shelf[$i]->name; + echo $shelfName; + + $url = "http://www.goodreads.com/review/list/$grID?shelf=$shelfName&format=xml&key=8vxmKmAn8AVolobtvBbMIg"; + //echo $url; + curl_setopt ($crl, CURLOPT_URL,$url); + $ret1 = curl_exec($crl); + + $ret1 = preg_replace("/[^[:alnum:][:punct:][:space:]]/"," ",$ret1); + $ret1 = convert_utf8($ret1); + //echo "%%" . $ret1 . "**"; + $xml1 = new SimpleXMLElement($ret1); + for($j=0;$j<sizeof($xml1->books->book);$j++){ + //echo $xml1->books->book[$j]->isbn . "\n"; + $isbn = trim($xml1->books->book[$j]->isbn); + $picURL = trim($xml1->books->book[$j]->image_url); + $title = trim($xml1->books->book[$j]->title); + //echo $title; + $add = "CALL insertUserSave($userID,\"$shelfName\",'$isbn','$picURL',\"$title\")"; + //echo $add; + $run = mysqli_query($link, $add); //add the book to the list in usersave + } + } + //curl_close($crl); + //session_start(); + $backLoc = "http://www.yournextread.com/" . urldecode($_SESSION['backLocation']); + + echo + "<html> + <link rel=\"stylesheet\" type=\"text/css\" href=\"../user/style.css\"> + <head> + <title>Goodreads Import Successful</title> + </head> + <body> + + <h1>YourNextRead</h1> + <p>Thank you! Your Goodreads Lists have successfully been imported to your YourNextRead account</p> + <p>Click <a href=\"$backLoc\">here</a> to go back to YourNextRead</p> + + <p><a href=\"http://www.YourNextRead.com\">www.YourNextRead.com</a></p> + + </body> + </html>"; + +} +?> + + +