示例#1
0
 * Setup error reporting
 */
error_reporting(E_ALL);
ini_set('display_errors', 1);
/**
 * Setup the timezone
 */
ini_set('date.timezone', 'Europe/Amsterdam');
/**
 * Create a new instance of the URI class with the current URI, stripping the query string
 */
$uriFactory = new \OAuth\Common\Http\Uri\UriFactory();
$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER);
$currentUri->setQuery('');
$serviceFactory = new \OAuth\ServiceFactory();
$serviceFactory->registerService('projectplace', 'Crockett95\\ProjectPlace\\OAuthService');
/**
 * Load the credential for the different services
 */
$serviceCredentials = (require_once __DIR__ . '/keys.php');
// We need to use a persistent storage to save the token, because oauth1 requires the token secret received before'
// the redirect (request token request) in the access token request.
$storage = new Session();
// Setup the credentials for the requests
$credentials = new Credentials($serviceCredentials['key'], $serviceCredentials['secret'], $currentUri->getAbsoluteUri());
// Instantiate the twitter service using the credentials, http client and storage mechanism for the token
/** @var $twitterService Twitter */
$projectPlaceService = $serviceFactory->createService('projectplace', $credentials, $storage);
if (!empty($_GET['oauth_token'])) {
    $token = $storage->retrieveAccessToken('ProjectPlace');
    // This was a callback request from twitter, get the token