Skip to content

Instantly share code, notes, and snippets.

@wgroenewold
Created July 3, 2015 06:44
Show Gist options
  • Save wgroenewold/89632ae7fd217c10f58a to your computer and use it in GitHub Desktop.
Save wgroenewold/89632ae7fd217c10f58a to your computer and use it in GitHub Desktop.
ohmy-auth Yammer
<?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>';
});
@wgroenewold
Copy link
Author

Requires the ohmy-auth library: https://github.com/sudocode/ohmy-auth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment