Mercurial > hg > ywww
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/goodreads/callback.php Thu Feb 16 22:29:02 2017 +0000 @@ -0,0 +1,65 @@ +<?php + +require_once('GoodreadsAPI.php'); + +session_start(); +if($_SESSION['oauth_token'] !== $_REQUEST['oauth_token']) +{ + //token expired get a new one. You can clear session over here and redirect user to the login link + die('Goodreads connection expired- please reconnect'); +} + + +$obj = new GoodreadsApi(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']); + +$access_token = $obj->getAccessToken($_REQUEST['oauth_verifier']); +$_SESSION['access_token'] = $access_token; + +//print_r($access_token); + +unset ($_SESSION['oauth_token'], $_SESSION['oauth_token_secret'] ,$obj); + +$obj = new GoodreadsApi(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']); + +$content = $obj->doGet('http://www.goodreads.com/api/auth_user'); +//print_r($content); + +$xml = new SimpleXMLElement($content); +$grID = $xml->user->attributes()->id; +//echo $grID; + +$userID = $_SESSION['UserID']; +$backLoc = "http://www.yournextread.com/" . urldecode($_SESSION['backLocation']); + +include "../../private/db.php"; +$add = "CALL addGoodreadsID($userID,$grID)"; +//echo $add; +$run = mysqli_query($link, $add); //add the book to the list in usersave + + +unset ($obj); + + echo "<html> + <link rel=\"stylesheet\" type=\"text/css\" href=\"../user/style.css\"> + <head> + <title>Goodreads Connection Successful</title> + </head> + <body> + + <h1>YourNextRead</h1> + <p>Thank you! You have successfully connected YourNextRead and Goodreads!</p> + <div style=\"border-bottom:solid;border-bottom-width:2px;border-bottom-color:#ffffff;height:1px;width:100%;margin-top:10px;margin-bottom:10px;\"></div> + <p>Use this button to import your Goodreads shelves into YourNextRead:</p> + <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> + <p>Use this button to export all of your YourNextRead saved lists into Goodreads:</p> + <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> + <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> + <div style=\"border-bottom:solid;border-bottom-width:2px;border-bottom-color:#ffffff;height:1px;width:100%;margin-top:10px;margin-bottom:10px;\"></div> + <p>Click <a href=\"$backLoc\">here</a> to go to your previous page on YourNextRead</p> + <p><a href=\"$backLoc\">www.YourNextRead.com</a></p> + + </body> + </html>"; + +//Header( "Location: ../xml/getGoodReadsShelves.php?userID=$userID&grID=$grID" ); +?> \ No newline at end of file