Mercurial > hg > ywww
view goodreads/bkp/callback.php @ 15:385ddd7c4b55 testing
use test_db.php to get mysqld_test instance
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Sun, 19 Feb 2017 16:17:53 +0000 |
parents | 077b0a0a3e6d |
children |
line wrap: on
line source
<?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('Error connecting to Goodreads - please try again'); } $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); //you may have to 'view page source' if the relevant XML is not visible in your browser $xml = new SimpleXMLElement($content); $grID = $xml->user->attributes()->id; //echo $grID; $userID = $_SESSION['UserID']; //echo $userID; include "../../../private/db_test.php"; $add = "CALL addGoodreadsID($userID,$grID)"; $run = mysqli_query($link, $add); unset ($obj); Header( "Location: ../goodreads/syncGoodreadsShelves.php?userID=$userID&grID=$grID" ); ?>