我该从哪里出发?这几乎只是从sdk中提供的示例复制粘贴。我不明白人们如何使用这个API来构建任何东西?我如何打开登录等提示屏幕? Facebook在那里说了些什么?Facebook API帮助
<?php
require 'fb_sdk/src/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => 'APIID',
'secret' => 'SECRET',
));
// Get User ID
$user = $facebook->getUser();
// We may or may not have this data based on whether the user is logged in.
//
// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Permissions requested from the user.
$par = array();
$par['scope'] = 'user_about_me, read_friendlists';
// Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl($par);
}
?>
g^ood answer,至于@Jollygood:不要为此考虑API。它在那里*帮助*你的应用程序。一旦你清楚了解你的应用程序将提供什么,那么与Facebook API的集成点就会明确。以这个[示例](http://developers.facebook.com/docs/samples/canvas/)应用程序为例,您会意识到您的应用程序创意,并得出结论,您需要用户全名,电子邮件,照片和来自Facebook的朋友并相应地使用API。 – ifaour