view goodreads/bkp/callback.php @ 59:e4c78b3eace7

stop bothering Amazon.co.uk at all
author Charlie Root
date Sun, 09 Jun 2019 06:49:35 -0400
parents a67bf725e87b
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 "db.php"; 
$add = "CALL addGoodreadsID($userID,$grID)"; 
$run = mysqli_query($link, $add); 

unset ($obj);
Header( "Location: ../goodreads/syncGoodreadsShelves.php?userID=$userID&grID=$grID" ); 
?>