Skip to content

Instantly share code, notes, and snippets.

@patik
Created October 11, 2012 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patik/3874035 to your computer and use it in GitHub Desktop.
Save patik/3874035 to your computer and use it in GitHub Desktop.
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