tutik/socialist

There is no license information available for the latest version (dev-master) of this package.

Then (^_^) ...

dev-master 2013-12-19 15:19 UTC

This package is auto-updated.

Last update: 2024-12-22 04:42:49 UTC


README

Laravel Socialist Package

Installation

You should install this package through Composer.

Edit your project's composer.json file to require tutik/socialist.

"require": {
	"laravel/framework": "4.x",
	"tutik/socialist": "dev-master"
},
"minimum-stability" : "dev"

Next, update Composer from the Terminal: composer update

Once this operation completes, the final step is to add the service provider. Open app/config/app.php, and add a new item to the providers array.

'Tutik\Socialist\SocialistServiceProvider',

Usage

Create config file in base folder app

/app/config/api/socialist.php

return [

    'vk' => [
        'app_id'       => '',
        'app_key'      => '',
        'redirect_url' => 'http://site/socialist',
    ],
    'mailru' => [
        'app_id'            => ,
        'app_key_private'   => '',
        'app_key'           => '',
        'redirect_url'      => 'http://site/socialist',
    ],

    'fb' => [
        'app_id'       => '',
        'app_key'      => '',
        'redirect_url' => 'http://site/socialist',
    ],
];

Create a controller and use

<?php
use \Tutik\Socialist\Socialist;
// VKontakte
$response = Socialist::factory('vk')->api('users.get',[
  'users_id' => '100500',   
  'access_token' => <access_token>,
]);
$response = array_shift($data['response']);
// MailRu
$mail = Socialist::factory('mailru');
if ($uid  = $mail->isAuth()) {
    $response = $mail->api('users.getInfo', array('uids' => $uid));
    $response = array_shift($response);   // User Data
}
// Facebook
$facebook = Socialist::factory('facebook'); // or alias fb
$user = $facebook->getUser();
if ($user) {
  try {
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    $user = null;
  }
}
// @TODO Google+