Mercurial > hg > ywww
comparison 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 |
comparison
equal
deleted
inserted
replaced
5:55445b456ad0 | 6:077b0a0a3e6d |
---|---|
1 <?php | |
2 include "UTFUtil.php"; | |
3 | |
4 $userID=$_GET['userID']; | |
5 $grID=$_GET['grID']; | |
6 if( $userID == "" || $grID == "") | |
7 { | |
8 echo "<html> | |
9 <link rel=\"stylesheet\" type=\"text/css\" href=\"../user/style.css\"> | |
10 <head> | |
11 <title>YourNextRead Export Unsuccessful</title> | |
12 </head> | |
13 <body> | |
14 | |
15 <h1>YourNextRead</h1> | |
16 <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> | |
17 <p>Click <a href=\"http://www.yournextread.com\">here</a> to go back to YourNextRead</p> | |
18 | |
19 <p>www.YourNextRead.com</p> | |
20 | |
21 </body> | |
22 </html>"; | |
23 } | |
24 else | |
25 { | |
26 | |
27 require_once('GoodreadsAPI.php'); | |
28 session_start(); | |
29 $access_token = $_SESSION['access_token']; | |
30 //print_r($access_token); | |
31 $obj = new GoodreadsApi(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']); | |
32 $ret = $obj->doGet('http://www.goodreads.com/review/list.xml?v=2', array("id" => "$grID")); | |
33 //print_r($content); | |
34 | |
35 //$url= "http://www.goodreads.com/shelf/list?format=xml&key=8vxmKmAn8AVolobtvBbMIg&user_id=" . $grID; | |
36 //echo $url; | |
37 | |
38 /*$crl = curl_init(); | |
39 $timeout = 5; | |
40 curl_setopt ($crl, CURLOPT_URL,$url); | |
41 curl_setopt ($crl, CURLOPT_ENCODING , "gzip"); | |
42 curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); | |
43 curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); | |
44 $ret = curl_exec($crl); */ | |
45 $ret = preg_replace("/[^[:alnum:][:punct:][:space:]]/","",$ret); | |
46 echo $ret; | |
47 | |
48 include "../../private/db.php"; | |
49 | |
50 $xml = new SimpleXMLElement(convert_utf8($ret)); | |
51 for($i=0;$i<sizeof($xml->shelves->user_shelf);$i++){ | |
52 | |
53 $shelfName= $xml->shelves->user_shelf[$i]->name; | |
54 echo $shelfName; | |
55 | |
56 $url = "http://www.goodreads.com/review/list/$grID?shelf=$shelfName&format=xml&key=8vxmKmAn8AVolobtvBbMIg"; | |
57 //echo $url; | |
58 curl_setopt ($crl, CURLOPT_URL,$url); | |
59 $ret1 = curl_exec($crl); | |
60 | |
61 $ret1 = preg_replace("/[^[:alnum:][:punct:][:space:]]/"," ",$ret1); | |
62 $ret1 = convert_utf8($ret1); | |
63 //echo "%%" . $ret1 . "**"; | |
64 $xml1 = new SimpleXMLElement($ret1); | |
65 for($j=0;$j<sizeof($xml1->books->book);$j++){ | |
66 //echo $xml1->books->book[$j]->isbn . "\n"; | |
67 $isbn = trim($xml1->books->book[$j]->isbn); | |
68 $picURL = trim($xml1->books->book[$j]->image_url); | |
69 $title = trim($xml1->books->book[$j]->title); | |
70 //echo $title; | |
71 $add = "CALL insertUserSave($userID,\"$shelfName\",'$isbn','$picURL',\"$title\")"; | |
72 //echo $add; | |
73 $run = mysqli_query($link, $add); //add the book to the list in usersave | |
74 } | |
75 } | |
76 //curl_close($crl); | |
77 //session_start(); | |
78 $backLoc = "http://www.yournextread.com/" . urldecode($_SESSION['backLocation']); | |
79 | |
80 echo | |
81 "<html> | |
82 <link rel=\"stylesheet\" type=\"text/css\" href=\"../user/style.css\"> | |
83 <head> | |
84 <title>Goodreads Import Successful</title> | |
85 </head> | |
86 <body> | |
87 | |
88 <h1>YourNextRead</h1> | |
89 <p>Thank you! Your Goodreads Lists have successfully been imported to your YourNextRead account</p> | |
90 <p>Click <a href=\"$backLoc\">here</a> to go back to YourNextRead</p> | |
91 | |
92 <p><a href=\"http://www.YourNextRead.com\">www.YourNextRead.com</a></p> | |
93 | |
94 </body> | |
95 </html>"; | |
96 | |
97 } | |
98 ?> | |
99 | |
100 | |
101 |