Mercurial > hg > ywww
comparison goodreads/bkp/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('Error connecting to Goodreads - please try again'); | |
| 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 //you may have to 'view page source' if the relevant XML is not visible in your browser | |
| 27 $xml = new SimpleXMLElement($content); | |
| 28 $grID = $xml->user->attributes()->id; | |
| 29 //echo $grID; | |
| 30 $userID = $_SESSION['UserID']; | |
| 31 //echo $userID; | |
| 32 | |
| 33 include "../../private/db.php"; | |
| 34 $add = "CALL addGoodreadsID($userID,$grID)"; | |
| 35 $run = mysqli_query($link, $add); | |
| 36 | |
| 37 unset ($obj); | |
| 38 Header( "Location: ../goodreads/syncGoodreadsShelves.php?userID=$userID&grID=$grID" ); | |
| 39 ?> |
