tutik / socialist
本包最新版本(dev-master)没有可用的许可证信息。
然后 (^_^) ...
dev-master
2013-12-19 15:19 UTC
Requires
- php: >=5.4.0
- illuminate/support: 4.x
This package is auto-updated.
Last update: 2024-09-22 04:07:44 UTC
README
Laravel Socialist 包
安装
您应该通过 Composer 安装此包。
编辑您项目的 composer.json
文件,以添加对 tutik/socialist
的依赖。
"require": {
"laravel/framework": "4.x",
"tutik/socialist": "dev-master"
},
"minimum-stability" : "dev"
接下来,在终端中更新 Composer: composer update
完成此操作后,最后一步是添加服务提供者。打开 app/config/app.php
,并将新的项添加到 providers 数组中。
'Tutik\Socialist\SocialistServiceProvider',
使用
在基本目录 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', ], ];
创建控制器并使用
<?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+