PHP ~ test connect to Facebook ~ get user info

最近測試用PHP連線Facebook~~

我是下載人家的demo~~~~
http://wiki.developers.facebook.com/index.php/Connect/Demos

用他的檔案做測試的~~~~

大致上要做的有~~~~~申請Facebook Application

取得API Key 跟 Secret~~~然後在config.php貼上

線上設定Application的URL~~~~~~就好了~


取facebook帳號資料~~~

define(MAIN_PATH, realpath('.'));
include_once MAIN_PATH.'/lib/config.php';
include_once MAIN_PATH.'/lib/core.php';
include_once MAIN_PATH.'/lib/fbconnect.php';
include_once MAIN_PATH.'/lib/user.php';
include_once MAIN_PATH.'/facebook-client/facebook.php';

$user = User::getLoggedIn();

if (!$user) {
echo render_logged_out_index();
echo render_footer();
exit;
}
else
{
if ($user->is_facebook_user()) {
$xxx = facebook_client()->api_client->users_getInfo($user->fb_uid, 'last_name, first_name, website,  sex, birthday ');
print_r($xxx);
}
}


output
Array ( [0] => Array ( [birthday] => June 18, 9999 [first_name] => qqqq [last_name] => ffffffffff [sex] => male [uid] => 11111111111111111 [website] => http://bittyferrari.blogspot.com/ ) )


http://developers.facebook.com/tools.php?api

http://wiki.developers.facebook.com/index.php/Users.getInfo

沒有留言:

發佈留言