PHP code example of stephenyeargin / yammer-oauth2-php

1. Go to this page and download the library: Download stephenyeargin/yammer-oauth2-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stephenyeargin / yammer-oauth2-php example snippets


// Redirect the user to the OAuth page for your application
header('Location: ' . $yammer->getAuthorizationUrl());

$code = $_GET['code'];
$token = $yammer->getAccessToken($code);

$yammer->setOAuthToken($token);

if (!$yammer->testAuth()) {
    // Handle this.
}

// Retrieve feed for authenticated user
try {
    $feed = $yammer->get('messages/my_feed.json');
    print_r($feed);
} catch (YammerPHPException $e) {
    print 'Error: ';
    print $e->getMessage();
}
bash
$ composer 

$config['consumer_key'] = '1ABCdefhiJKLmnop';
$config['consumer_secret'] = 'ABCdefhi_JKLmnop';
$config['callbackUrl'] = 'http://' . $_SERVER['SERVER_NAME'] . '/yammer/callback/';

$yammer = new YammerPHP\YammerPHP($config);