- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
因为我已经搜索了很多东西来使用脚本或 php 来统计 friend 数量。但我无法得到实际结果。大多数结果只会显示这些东西。
自 2014 年 7 月 22 日星期二起,我们现在在对/v2.2/me/friends 的响应中的摘要属性中返回一个 total_count 字段。
但我不知道如何统计好友数。请帮助我,我浪费了一整天的时间来得到这个。
我试过下面的代码来统计我的 friend 数
<!DOCTYPE html>
<html>
<head>
<title>Facebook Login JavaScript Example</title>
<meta charset="UTF-8">
</head>
<body>
<script>
// This is called with the results from from FB.getLoginStatus().
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
// The response object is returned with a status field that lets the
// app know the current login status of the person.
// Full docs on the response object can be found in the documentation
// for FB.getLoginStatus().
if (response.status === 'connected') {
// Logged into your app and Facebook.
testAPI();
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';
} else {
// The person is not logged into Facebook, so we're not sure if
// they are logged into this app or not.
document.getElementById('status').innerHTML = 'Please log ' +
'into Facebook.';
}
}
// This function is called when someone finishes with the Login
// Button. See the onlogin handler attached to it in the sample
// code below.
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : 'My app Id',
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v2.4' // use version 2.2
});
// Now that we've initialized the JavaScript SDK, we call
// FB.getLoginStatus(). This function gets the state of the
// person visiting this page and can return one of three states to
// the callback you provide. They can be:
//
// 1. Logged into your app ('connected')
// 2. Logged into Facebook, but not your app ('not_authorized')
// 3. Not logged into Facebook and can't tell if they are logged into
// your app or not.
//
// These three cases are handled in the callback function.
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
// Load the SDK asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// Here we run a very simple test of the Graph API after login is
// successful. See statusChangeCallback() for when this call is made.
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Successful login for: ' + response.name);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + '!';
});
}
</script>
<!--
Below we include the Login Button social plugin. This button uses
the JavaScript SDK to present a graphical Login button that triggers
the FB.login() function when clicked.
-->
<fb:login-button scope="public_profile,email" onlogin="checkLoginState();">
</fb:login-button>
<div id="status">
</div>
</body>
</html>
在 FB.api('/me', function(response) {
它将返回我的用户 ID 和名称,我已经尝试过 FB.api('/me/friends', function(response) {
它返回一个空数组..
请帮我解决这个问题..
最佳答案
为了从版本 2+ 获取好友列表,FB 添加了一个额外的权限 user_friends
,您必须要求用户访问他的好友列表。从您上面的代码看来您没有权限。将 user_friends
添加到范围参数。
所以你的登录按钮参数应该是这样的
<fb:login-button scope="public_profile,email,user_friends" onlogin="checkLoginState();">
</fb:login-button>
提示:您可以使用以下网址来检查您是否拥有该权限。
GET /{user-id}/permissions
如果您已经获得许可,并且因为从版本 2+ /me/friends
返回了用户的也在使用您的应用程序的 friend ,并且您的应用程序相对较新,所以您得到的响应是空的您的 friend 可能都没有在使用该应用程序。
您可能想阅读 upgrade guide来自 Facebook 以更好地了解它。
关于javascript - 如何在开发者api2.4中获取facebook好友列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31774585/
namespace GameForge { namespace Core { class CTribool; } } GameForge::Core::CTri
有没有什么方法可以限制 PHP 中的可见性,就像“包”可见性在 Java 中起作用或至少“ friend ”可见性在 C++ 中起作用一样?维护大型 OOP 项目并且不让任何人使用代码的任何部分的最佳
我实际上是在尝试让一个模板类与另一个模板类成为 friend 。类似的东西: #include template class Test1 { private: static int
我创建了一个应用程序,我试图通过 facebook 邀请 friend js 方法邀请 friend ,但一切正常,但没有向该 friend 发送通知。 我的申请链接:http://www.huzoo
我正在建立一个网站。我希望用户邀请 Facebook 好友查看用户可以在我的网站上创建的页面。所以我正在努力完成它。但我认为 FB Api 没有设置来做我想做的事情。我认为这是为了防止垃圾邮件,但我真
当用户通过 Facebook 注册我的网站时。它使用 Facebook 身份验证 API 在“注册”按钮旁边返回“3 位 friend 已注册”。 def facebook_authenticated
几周前我开始使用 Android 编程。而且我有一些 Java 技能。 所以我正在创建一个应用程序,它需要获取 Facebook 好友列表(只是名字而不是图片)。我用谷歌搜索,大多数人都说“阅读 Fa
我正在寻找一种连接到 Facebook 的方法,允许用户输入他们的用户名和密码,然后让我们的应用程序连接到他们的帐户并获取他们的联系人,以便他们可以邀请他们加入我们网站上的群组。我以前写过一个 Fac
我需要的功能是在自定义设计的网站页面上向用户显示 Facebook 好友列表,用户可以在其中选择其中一些并发送邀请。 在 API v2.0 中,可以通过这种方式获取好友列表: FB.api('/me/
我正在创建一个应用程序,并希望使用该应用程序的人可以在 Facebook 上找到使用相同应用程序的 friend 。在这方面的任何帮助都会很棒。 我知道这是可以做到的。我在 Instagram 和 T
我正在尝试访问用户 friend ,但我似乎无法弄清楚我将如何去做。没有明确的方法来访问 friend 列表,所以我认为它可能是一个属性,但这似乎不起作用。我正在尝试浏览文档并找到了一些有用的信息 h
我已经成功获取了好友列表: //token NSString *acessToken = [NSString stringWithFormat:@"%@",_facebookAccount.crede
我正在尝试获取用户的 facebook 好友列表,但它只返回好友的数量。下面是我的代码。这段代码有什么问题吗? -(void)loginViewFetchedUserInfo:(FBLoginView
我在我的应用程序中集成了 Facebook SDK。 我想获取安装了我的应用程序的 Facebook 好友列表。该列表应包含他们的详细信息,例如 Facebook 电子邮件 ID、Facebook 名
当有人访问我的网页时,我想让他将访问过的网页分享到他的Facebook好友墙上,以便其他人也可以点击共享链接进入访问过的网页。条件:访问的网页应该出现在选定 friend 的 Facebook 墙上,
我的类(class) Bloque 是我其他类(class) user 的 friend ,我想传递我的 user 类到我的 Bloque 类上名为 void colision() 的函数。 所以我尝
我尝试使用 this link这个。在本教程中,我只发布我的应用程序链接到我的墙上。但我想与所有 friend 分享我的应用程序链接。就像 XYZ 邀请您尝试 ABCapp 一样,只在通知栏中。当点击
我正在使用 Facebook Android SDK。有没有一种简单的方法可以让用户的 friend 下载该应用程序?例如,应用程序 Draw Something 实现了这一点。我似乎找不到关于这个主
我有一个 Flutter 应用程序,您可以在其中使用 Facebook 登录。 ( https://pub.dev/packages/flutter_facebook_login )。 当用户登录时,
我想显示我的 VK 好友列表。 private ArrayList Friends = new ArrayList(); Friends = api.getFriends(account.user_
我是一名优秀的程序员,十分优秀!