Mercurial > hg > ywww
comparison goodreads/callback.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 | |
3 require_once('GoodreadsAPI.php'); | |
4 | |
5 session_start(); | |
6 if($_SESSION['oauth_token'] !== $_REQUEST['oauth_token']) | |
7 { | |
8 //token expired get a new one. You can clear session over here and redirect user to the login link | |
9 die('Goodreads connection expired- please reconnect'); | |
10 } | |
11 | |
12 | |
13 $obj = new GoodreadsApi(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']); | |
14 | |
15 $access_token = $obj->getAccessToken($_REQUEST['oauth_verifier']); | |
16 $_SESSION['access_token'] = $access_token; | |
17 | |
18 //print_r($access_token); | |
19 | |
20 unset ($_SESSION['oauth_token'], $_SESSION['oauth_token_secret'] ,$obj); | |
21 | |
22 $obj = new GoodreadsApi(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']); | |
23 | |
24 $content = $obj->doGet('http://www.goodreads.com/api/auth_user'); | |
25 //print_r($content); | |
26 | |
27 $xml = new SimpleXMLElement($content); | |
28 $grID = $xml->user->attributes()->id; | |
29 //echo $grID; | |
30 | |
31 $userID = $_SESSION['UserID']; | |
32 $backLoc = "http://www.yournextread.com/" . urldecode($_SESSION['backLocation']); | |
33 | |
34 include "../../private/db.php"; | |
35 $add = "CALL addGoodreadsID($userID,$grID)"; | |
36 //echo $add; | |
37 $run = mysqli_query($link, $add); //add the book to the list in usersave | |
38 | |
39 | |
40 unset ($obj); | |
41 | |
42 echo "<html> | |
43 <link rel=\"stylesheet\" type=\"text/css\" href=\"../user/style.css\"> | |
44 <head> | |
45 <title>Goodreads Connection Successful</title> | |
46 </head> | |
47 <body> | |
48 | |
49 <h1>YourNextRead</h1> | |
50 <p>Thank you! You have successfully connected YourNextRead and Goodreads!</p> | |
51 <div style=\"border-bottom:solid;border-bottom-width:2px;border-bottom-color:#ffffff;height:1px;width:100%;margin-top:10px;margin-bottom:10px;\"></div> | |
52 <p>Use this button to import your Goodreads shelves into YourNextRead:</p> | |
53 <center><A HREF=\"http://www.yournextread.com/goodreads/getGoodreadsShelves.php?userID=$userID&grID=$grID\"><img src=\"http://www.yournextread.com/images/goodreads-import.png\" style=\"border:0px;display:block;\" alt=\"Import from Goodreads\"></a></center> | |
54 <p>Use this button to export all of your YourNextRead saved lists into Goodreads:</p> | |
55 <center><A HREF=\"http://www.yournextread.com/goodreads/syncGoodreadsShelves.php?userID=$userID&grID=$grID\"><img src=\"http://www.yournextread.com/images/goodreads-export.png\" style=\"border:0px;display:block;\" alt=\"Export to Goodreads\"></a></center> | |
56 <p><b>Note</b> - if you have many saved lists the export process can take some time. You may prefer to export individual lists, using the <img src=\"http://www.yournextread.com/images/goodreads-save.png\" style=\"border:0px;display:inline;\" alt=\"Save to Goodreads\"> button in the 'Saved List' tab</p> | |
57 <div style=\"border-bottom:solid;border-bottom-width:2px;border-bottom-color:#ffffff;height:1px;width:100%;margin-top:10px;margin-bottom:10px;\"></div> | |
58 <p>Click <a href=\"$backLoc\">here</a> to go to your previous page on YourNextRead</p> | |
59 <p><a href=\"$backLoc\">www.YourNextRead.com</a></p> | |
60 | |
61 </body> | |
62 </html>"; | |
63 | |
64 //Header( "Location: ../xml/getGoodReadsShelves.php?userID=$userID&grID=$grID" ); | |
65 ?> |