Skip to content

Instantly share code, notes, and snippets.

@ChrisFrench
Created June 4, 2014 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisFrench/13e00f68fabfdc2e0d29 to your computer and use it in GitHub Desktop.
Save ChrisFrench/13e00f68fabfdc2e0d29 to your computer and use it in GitHub Desktop.
yammerexample.php
<?php
namespace Mgx\Site\Controllers;
class Yammer extends Auth
{
var $provider = 'yammer';
public function index()
{
$f3 = \Base::instance();
$hybridauth_config = \Users\Models\Settings::fetch();
$config = (array) $hybridauth_config->{'social'};
if (empty($config['base_url'])) {
$config['base_url'] = $f3->get('SCHEME') . '://' . $f3->get('HOST') . $f3->get('BASE') . '/login/social';
}
// create an instance for Hybridauth with the configuration file path as parameter
$hybridauth = new \Hybrid_Auth( $config );
// check if the user is currently connected to the selected provider
if( ! $hybridauth->isConnectedWith( $this->provider ) ){
// redirect him back to login page
$f3->reroute('login');
}
// call back the requested provider adapter instance (no need to use authenticate() as we already did on login page)
$adapter = $hybridauth->getAdapter( $this->provider );
// grab the user profile
$user_data = $adapter->getUserProfile();
$f3->set('profile', $user_data);
$view = \Dsc\System::instance()->get( 'theme' );
echo $view->render('Mgx/Site/Views::yammer/index.php');
}
public function contacts()
{
$f3 = \Base::instance();
$hybridauth_config = \Users\Models\Settings::fetch();
$config = (array) $hybridauth_config->{'social'};
if (empty($config['base_url'])) {
$config['base_url'] = $f3->get('SCHEME') . '://' . $f3->get('HOST') . $f3->get('BASE') . '/login/social';
}
// create an instance for Hybridauth with the configuration file path as parameter
$hybridauth = new \Hybrid_Auth( $config );
// check if the user is currently connected to the selected provider
if( ! $hybridauth->isConnectedWith( $this->provider ) ){
// redirect him back to login page
$f3->reroute('login');
}
// call back the requested provider adapter instance (no need to use authenticate() as we already did on login page)
$adapter = $hybridauth->getAdapter( $this->provider );
// grab the user profile
$data = $adapter->getUserContacts();
$f3->set('contacts', $data);
$view = \Dsc\System::instance()->get( 'theme' );
echo $view->render('Mgx/Site/Views::yammer/contacts.php');
}
public function messages()
{
$f3 = \Base::instance();
$hybridauth_config = \Users\Models\Settings::fetch();
$config = (array) $hybridauth_config->{'social'};
if (empty($config['base_url'])) {
$config['base_url'] = $f3->get('SCHEME') . '://' . $f3->get('HOST') . $f3->get('BASE') . '/login/social';
}
// create an instance for Hybridauth with the configuration file path as parameter
$hybridauth = new \Hybrid_Auth( $config );
// check if the user is currently connected to the selected provider
if( ! $hybridauth->isConnectedWith( $this->provider ) ){
// redirect him back to login page
$f3->reroute('login');
}
// call back the requested provider adapter instance (no need to use authenticate() as we already did on login page)
$adapter = $hybridauth->getAdapter( $this->provider );
// grab the user profile
$user_data = $adapter->getUserMessages();
$f3->set('messages', $user_data);
$view = \Dsc\System::instance()->get( 'theme' );
echo $view->render('Mgx/Site/Views::yammer/messages.php');
}
public function showPost()
{
$f3 = \Base::instance();
$view = \Dsc\System::instance()->get( 'theme' );
echo $view->render('Mgx/Site/Views::yammer/post.php');
}
public function doPost()
{
$f3 = \Base::instance();
$view = \Dsc\System::instance()->get( 'theme' );
echo $view->render('Mgx/Site/Views::yammer/post.php');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment