comparison goodreads/bkp/working/getGoodreadsShelves.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 $url= "http://www.goodreads.com/shelf/list?format=xml&key=8vxmKmAn8AVolobtvBbMIg&user_id=" . $grID;
27 //echo $url;
28
29 $crl = curl_init();
30 $timeout = 5;
31 curl_setopt ($crl, CURLOPT_URL,$url);
32 curl_setopt ($crl, CURLOPT_ENCODING , "gzip");
33 curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
34 curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
35 $ret = curl_exec($crl);
36 $ret = preg_replace("/[^[:alnum:][:punct:][:space:]]/","",$ret);
37 //echo $ret;
38
39 include "../../private/db.php";
40
41 $xml = new SimpleXMLElement(convert_utf8($ret));
42 for($i=0;$i<sizeof($xml->shelves->user_shelf);$i++){
43
44 $shelfName= $xml->shelves->user_shelf[$i]->name;
45 //echo $shelfName;
46
47 $url = "http://www.goodreads.com/review/list/$grID?shelf=$shelfName&format=xml&key=8vxmKmAn8AVolobtvBbMIg";
48 curl_setopt ($crl, CURLOPT_URL,$url);
49 $ret1 = curl_exec($crl);
50
51 $ret1 = preg_replace("/[^[:alnum:][:punct:][:space:]]/"," ",$ret1);
52 $ret1 = convert_utf8($ret1);
53 $xml1 = new SimpleXMLElement($ret1);
54 for($j=0;$j<sizeof($xml1->books->book);$j++){
55 //echo $xml1->books->book[$j]->isbn . "\n";
56 $isbn = trim($xml1->books->book[$j]->isbn);
57 $picURL = trim($xml1->books->book[$j]->image_url);
58 $title = trim($xml1->books->book[$j]->title);
59 //echo $title;
60 $add = "CALL insertUserSave($userID,\"Goodreads: $shelfName\",'$isbn','$picURL',\"$title\")";
61 //echo $add;
62 $run = mysqli_query($link, $add); //add the book to the list in usersave
63 }
64 }
65 curl_close($crl);
66
67 echo
68 "<html>
69 <link rel=\"stylesheet\" type=\"text/css\" href=\"../user/style.css\">
70 <head>
71 <title>Goodreads Import Successful</title>
72 </head>
73 <body>
74
75 <h1>YourNextRead</h1>
76 <meta http-equiv=\"refresh\" content=\"7; url=http://www.YourNextRead.com/\">
77 <p>Thank you! Your Goodreads Lists have successfully been imported to your YourNextRead account</p>
78 <p>Click <a href=\"javascript:window.history.go(-2)\">here</a> to go back to YourNextRead</p>
79
80 <p>www.YourNextRead.com</p>
81
82 </body>
83 </html>";
84
85 }
86 ?>
87
88
89