Mercurial > hg > ywww
view goodreads/getGoodreadsShelves.php @ 45:8bc395c87c6f
less built-in use of full site address
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Sun, 06 Jan 2019 08:09:47 -0500 |
parents | 077b0a0a3e6d |
children | 385ddd7c4b55 a67bf725e87b |
line wrap: on
line source
<?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 { $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"; 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']); $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; $ret1 = $obj->doGet('http://www.goodreads.com/review/list.xml?v=2', array("id" => "$grID","shelf" => "$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); //echo sizeof($xml1->reviews->review); for($j=0;$j<sizeof($xml1->reviews->review);$j++){ //echo $xml1->reviews[$j]->review->book->isbn . "\n"; $isbn = trim($xml1->reviews->review[$j]->book->isbn); $picURL = trim($xml1->reviews->review[$j]->book->image_url); $title = trim($xml1->reviews->review[$j]->book->title); //echo $title; $add = "CALL b_insertSaveList($userID,\"$shelfName\",'$isbn','$picURL',\"$title\")"; //echo $add; $run = mysqli_query($link, $add); //add the book to the list in usersave if($shelfName == "read") { $add = "CALL b_insertSaveList($userID,\"MyMap\",'$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>"; } ?>