Created
July 3, 2015 06:44
-
-
Save wgroenewold/89632ae7fd217c10f58a to your computer and use it in GitHub Desktop.
ohmy-auth Yammer
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 __DIR__ . '/vendor/autoload.php'; | |
use ohmy\Auth2; | |
# do 3-legged oauth | |
$yammer = Auth2::legs(3) | |
# configuration | |
->set(array( | |
'client_id' => '{yammer-clientid}', | |
'secret' => '{yammer-clientsecret}', | |
'redirect_uri' => '{yammer-redirecturi}' | |
)) | |
# oauth flow | |
->authorize('https://www.yammer.com/dialog/oauth') | |
->access('https://www.yammer.com/oauth2/access_token.json') | |
->finally(function($data) use(&$access_token) { | |
$access_token = $data['access_token']['token']; | |
}); | |
# access Yammer api | |
$yammer->GET("https://www.yammer.com/api/v1/users.json", array(), array('User-Agent' => 'ohmy-auth', 'Authorization' => 'Bearer ' . $access_token)) | |
->then(function($data) { | |
echo '<pre>'; | |
var_dump($data->json()); | |
echo '</pre>'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires the ohmy-auth library: https://github.com/sudocode/ohmy-auth