Skip to content

Instantly share code, notes, and snippets.

@patik patik/adn-auth.php
Created Oct 11, 2012

Embed
What would you like to do?
ADN auth issue
<?php
require_once('keys.php'); // Where my constants are defined
require_once('AppDotNet.php');
$clientId = ADN_CLIENT_ID;
$clientSecret = ADN_CLIENT_SECRET;
$redirectUri = ADN_REDIRECT_URI;
# User has authorized:
if (isset($_GET['code']) && !empty($_GET['code'])) {
$app = new AppDotNet($clientId, $clientSecret);
// get the token returned by App.net
// (this also sets the token)
$token = $app->getAccessToken($redirectUri);
// get info about the user
$user = $app->getUser();
echo var_dump($user);
echo var_dump($token);
}
# User has not yet authorized:
else {
// construct the AppDotNet object
$app = new AppDotNet($clientId, $clientSecret);
$scope = array('stream','email','write_post','follow','messages');
// create an authentication Url
$url = $app->getAuthUrl($redirectUri,$scope);
echo '<p><a href="' . $url . '">Please log in</a></p>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.