/** * oauth-example-getAccessToken * * Demonstrate the use of the getAccessToken() function from the OAuth_1a class * * @package OAuth_1a * @author Joshua Zeitlinger <*****@*****.**> * @link https://github.com/joshuaspring9/Oauth_1a * @version 0.2 * * * History: * version 0.1.1 - file created * version 0.2 - add try/catch block for exceptions * */ //show all errors while we debug error_reporting(E_ALL); ini_set('display_errors', 1); session_start(); require "../OAuth_1a.php"; try { $s = new OAuth_1a("consumer", "consumer_secret", "HMAC-SHA1", "AUTHORIZATION"); $s->setToken($_GET['oauth_token'], $_SESSION['secret']); $result = $s->getAccessToken("http://api.shapeways.com/oauth1/access_token/v1", $_GET['oauth_verifier'], "GET"); $data = $s->getLastResponse(); print_r($data); } catch (OAuth_1a_Exception $e) { print_r($e->getAll()); }
<?php /** * oauth-example-fetch * * Demonstrate the use of the fetch() function from the OAuth_1a class * * @package OAuth_1a * @author Joshua Zeitlinger <*****@*****.**> * @link https://github.com/joshuaspring9/Oauth_1a * @version 0.2 * * * History: * version 0.1.1 - file created * version 0.2 - add try/catch block for exceptions * */ //show all errors while we debug error_reporting(E_ALL); ini_set('display_errors', 1); require "../OAuth_1a.php"; try { $s = new OAuth_1a("consumer", "consumer_secret", "HMAC-SHA1", "AUTHORIZATION"); $s->setToken('oauth_token', 'oauth_token_secret'); $result = $s->fetch("http://api.shapeways.com/models/3629769/info/v1", null, "GET", array("Accept" => "application/json")); print $s->getLastResponse(); } catch (OAuth_1a_Exception $e) { //to see what info you can get, see the OAuth_1a_Exception class print_r($e->getAll()); }
/** * oauth-example-getRequestToken * * Demonstrate the use of the getRequestToken() function from the OAuth_1a class * * @package OAuth_1a * @author Joshua Zeitlinger <*****@*****.**> * @link https://github.com/joshuaspring9/Oauth_1a * @version 0.2 * * * History: * version 0.1.1 - file created * version 0.2 - add try/catch block for exceptions * */ //show all errors while we debug error_reporting(E_ALL); ini_set('display_errors', 1); session_start(); require "../OAuth_1a.php"; try { $s = new OAuth_1a("consumer", "consumer_sercret", "HMAC-SHA1", "AUTHORIZATION"); $result = $s->getRequestToken("http://api.shapeways.com/oauth1/request_token/v1", "http://yoursite.com/curl-example-geToken.php", "GET"); $data = $s->getLastResponse(); $_SESSION['secret'] = $data['oauth_token_secret']; header("Location: " . $data['authentication_url']); } catch (OAuth_1a_Exception $e) { print_r($e->getAll()); }