我将通过提及这是我第一次使用Facebook的API来启动这个问题。
我在自己的电脑上有一个脚本,用WAMP执行。它从Facebook的Graph API中获取数据,从Graph API Explorer 手动获取访问令牌时获取数据,获取特定群组的Feed。
我希望我的脚本要求访问令牌,然后使用file_get_contents
来请求 json字符串。我需要访问令牌才能拥有所有权限。
如何使下一步工作?
https://graph.facebook.com/GROUP_ID/feed?=access_token=ACCESS_TOKEN
答案 0 :(得分:2)
您正在寻找服务器端身份验证。关于此主题有detailed documentation。
答案 1 :(得分:1)
如果您正在开发 Facebook应用,则无需再次登录Facebook。 (PHP和Javascript的代码片段,使用您需要的。)
[PHP]
您可以通过 -
执行Http GET请求来获取access_tokenhttps://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials
有关详情:login as app
<强> [使用Javascript] 强>
FB.getLoginStatus(function(response)
{
if (response.status === 'connected')
{
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
}
else if (response.status === 'not_authorized')
{
// the user is logged in to Facebook,
// but has not authenticated your app
}
else
{
// the user isn't logged in to Facebook.
}
});
有关详细信息:getLoginStatus
如果您将fb与您的网站集成,您需要先登录,然后在回复中您可以获取访问令牌。
阅读本文:Login Architecture
[PHP] (难度:高)
阅读本文:server-side-login
[Javascript] (Dfifficulty:Low)
FB.login(function(response)
{
if (response.authResponse)
{
console.log('Welcome! Fetching your information.... ');
var access_token = response.authResponse.accessToken;
}
else
{
console.log('User cancelled login or did not fully authorize.');
}
});
更多详情:FB.Login