Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stephenyeargin/yammer-oauth2-php
🗣 PHP wrapper for Yammer's API
https://github.com/stephenyeargin/yammer-oauth2-php
hacktoberfest oauth2 php yammer
Last synced: 23 days ago
JSON representation
🗣 PHP wrapper for Yammer's API
- Host: GitHub
- URL: https://github.com/stephenyeargin/yammer-oauth2-php
- Owner: stephenyeargin
- License: mit
- Created: 2012-02-18T06:12:31.000Z (over 12 years ago)
- Default Branch: main
- Last Pushed: 2023-09-23T12:14:49.000Z (about 1 year ago)
- Last Synced: 2024-09-30T21:05:58.405Z (about 1 month ago)
- Topics: hacktoberfest, oauth2, php, yammer
- Language: PHP
- Homepage: https://packagist.org/packages/stephenyeargin/yammer-oauth2-php
- Size: 33.2 KB
- Stars: 10
- Watchers: 3
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Yammer OAuth2 for PHP
[![CI Build and Test](https://github.com/stephenyeargin/yammer-oauth2-php/actions/workflows/ci.yml/badge.svg)](https://github.com/stephenyeargin/yammer-oauth2-php/actions/workflows/ci.yml)
PHP wrapper for Yammer's API.
## Install
Install with Composer:
```bash
$ composer require stephenyeargin/yammer-oauth2-php
```## Usage
Example configuration array passed to constructor:
```
$config['consumer_key'] = '1ABCdefhiJKLmnop';
$config['consumer_secret'] = 'ABCdefhi_JKLmnop';
$config['callbackUrl'] = 'http://' . $_SERVER['SERVER_NAME'] . '/yammer/callback/';$yammer = new YammerPHP\YammerPHP($config);
```Starting the callback process:
```php
// Redirect the user to the OAuth page for your application
header('Location: ' . $yammer->getAuthorizationUrl());
```Upgrading the callback code to an authorization token:
```php
$code = $_GET['code'];
$token = $yammer->getAccessToken($code);
```Using the token (either from a fresh process or saved in the database)
```php
$yammer->setOAuthToken($token);
```Making a call with the `$yammer` instance:
```php
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();
}
```