[英]CodeIgniter Facebook integration
Is there a Codeigniter library available that allows me to 是否有可用的Codeigniter库
This library by Elliot Haughin should cover the login part but I'm less sure about importing profile data. Elliot Haughin的这个库应该包含登录部分,但我不太确定导入配置文件数据。
Anyone have information about this? 有人有这方面的信息吗?
The official Facebook PHP SDK actually works fine with Codeigniter. 官方的Facebook PHP SDK实际上可以与Codeigniter一起使用。
put base_facebook.php
and facebook.php
in your libraries
directory 把base_facebook.php
和facebook.php
放在你的libraries
目录中
create a facebook.php
file in your config directory with these contents 使用这些内容在config目录中创建一个facebook.php
文件
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$config['appId'] = 'YOUR_APP_ID_HERE';
$config['secret'] = 'YOUR_APP_SECRET_HERE';
then use it like this 然后像这样使用它
...
$this->load->library('facebook');
//Example usage from sdk example
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $this->facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $this->facebook->getLogoutUrl();
} else {
$loginUrl = $this->facebook->getLoginUrl();
}
...
but I'm less sure about importing profile data
Did you mean user profile data? 您的意思是用户个人资料数据? If you want to get full user data (including email, birthday, etc), dont forget to ask user permission for that, in your oauth url, like... 如果您想获得完整的用户数据(包括电子邮件,生日等),请不要忘记在您的oauth网址中询问用户的权限,例如......
$dialog_url = "http://www.facebook.com/dialog/oauth?client_id="
. $fb_app_id . "&redirect_uri=" . urlencode($fb_redirect_url)
. "&scope=email,user_about_me,user_activities,user_interests,user_events,user_groups,user_birthday"
. "&state="
. $facebook_csrf_state;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.