Created
October 11, 2012 17:17
-
-
Save patik/3874035 to your computer and use it in GitHub Desktop.
ADN auth issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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