diff goodreads/bkp/callbackDev.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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/goodreads/bkp/callbackDev.php	Thu Feb 16 22:29:02 2017 +0000
@@ -0,0 +1,32 @@
+<?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;
+
+unset ($obj);
+?>