Created
October 21, 2014 18:50
-
-
Save ArionHardison/0f77b5857f2e9dd6a626 to your computer and use it in GitHub Desktop.
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('PHP-OAuth2/src/OAuth2/Client.php'); | |
require('PHP-OAuth2/src/OAuth2/GrantType/IGrantType.php'); | |
require('PHP-OAuth2/src/OAuth2/GrantType/AuthorizationCode.php'); | |
$clientId = '9b8b0e1fe97d8efb3cb634ea65c03c8de269121894b980b1935db889aac11634'; | |
$clientSecret = 'afc5c60f67b00443d858efb9226b71da3a64873764ae4acf7d4a8cfc43cff91c'; | |
$client = new OAuth2\Client($clientId, $clientSecret); | |
$client->setCurlOption(CURLOPT_SSL_VERIFYPEER, true); | |
#NOTE: SET THE BELOW TO THE CODE YOU GET FROM THE CALLBACK | |
$code = 'd80bd609b7634d77fb6f38a444cfb093da6c596c98b49fc0099ff8864e30d8b8'; | |
$redirectUrl = 'http://www.example.com/oauth_callback'; | |
// generate a token response | |
$accessTokenUrl = 'https://arion.nationbuilder.com/oauth/token'; | |
$params = array('code' => $code, 'redirect_uri' => $redirectUrl); | |
$response = $client->getAccessToken($accessTokenUrl, 'authorization_code', $params); | |
// set the client token | |
$token = $response['result']['access_token']; | |
$client->setAccessToken($token); | |
$baseApiUrl = 'https://arion.nationbuilder.com'; | |
$client->setAccessToken($token); | |
$response = $client->fetch($baseApiUrl . '/api/v1/people'); | |
print_r($response); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment