如何显示正在使用应用程序的朋友的图像(代码)
我正在 Facebook 上开发一个应用程序。我的应用程序还有一个注册页面。当新用户进入我们的应用程序时,我希望该应用程序显示他正在使用该应用程序的所有朋友的图像。我该如何实现这个目标?
I am developing an application on facebook. My application also has an registration page. When a new user enters into our application I want the application to show the images of all his friends who are using this app. How do I accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此问题的解决方案需要您使用 Facebook 社交插件。
在用户安装您的应用程序之前,您无法构建自己的注册表单并向用户显示正在使用您的应用程序的所有朋友。这是因为,为了获取用户朋友的列表,您必须拥有有效的访问令牌 - 因为这不是公开信息。
您可以使用 2 种不同的社交插件。
简单的“登录”按钮,看起来像 Facebook 登录按钮。 (此处的文档:http://developers.facebook.com/docs/reference/plugins/ login/)
注册表单,使用用户的 Facebook 个人资料来预填充一些字段。您还可以向表单添加字段以获取更多信息。 (此处的文档:http://developers.facebook.com/docs/plugins/registration/)
这两者都显示已连接/安装的朋友的用户图片,这几乎是在用户授权您的应用程序之前实现此目的的唯一方法。
编辑 5/20/2011
在浏览 FB 社交插件文档后,我发现了另一个社交插件,如果您不想使用 Facebook 注册社交插件,您可以使用它。您可以使用 Facepile 插件。这显示了所有连接到您的应用程序、页面或您想要的任何内容的用户朋友。因此您可以构建自己的注册表单并使用此社交插件来实现您正在寻找的朋友照片结果。
The solution to this problem requires that you use a Facebook Social Plugin.
You can't build your own registration form and show a user all his/her friends who are using your application before the user installs your application. This is because, in order to get a list of the user's friends, you have to have a valid access token - as this isn't public information.
There are 2 different social plugins you can use.
The simple "login" button which looks like the Facebook login button. (documentation here: http://developers.facebook.com/docs/reference/plugins/login/)
A registration form, which uses their users' Facebook profile to pre-populate some fields. You can also add fields to the form to get more information. (documentation here: http://developers.facebook.com/docs/plugins/registration/)
Both of these show the user pictures of the friends that are already connected/installed, and this is pretty much the only way you can pull this off before the user authorizes your application.
edit 5/20/2011
After browsing around the FB Social Plugin docs, I found another Social Plugin that you could possibly use if you didn't want to use the Facebook Registration Social Plugin. You can use the Facepile Plugin. This shows all the users' friends who have connected to your app, or page, or whatever you want..so you could build your own registration form and use this social plugin to achieve the friends photos result you were looking for.
我想我看到了两种解决方案:
简单,在页面上的某个位置放置一个类似 facebook 的“带有面孔”的按钮,然后您的用户将看到“喜欢”您的页面的朋友的照片。
显示朋友图片的选项是
show_faces="true"
第二个选项,有点困难:
当新用户注册时:
https://graph.facebook.com/me/friends?access_token=...
在此处查看有关添加用户好友的更多信息:了解“朋友”连接。
I guess I see two solutions :
Simple, put a facebook like button "with faces" somewhere on your page, your users will then see the pictures of their friends who "liked" your page.
The option for showing friends pictures is
show_faces="true"
Second option, that is a bit more difficult :
When a new user registers :
https://graph.facebook.com/me/friends?access_token=...
<img src="http://graph.facebook.com/USER_FACEBOOK_ID/picture?type=small"></img>
See more about getting friends of a user here : read about the "friends" connection.
最好的方法是使用 facepile 你需要添加 data-app-id 并不要不添加 data-href 因为如果您添加 data-href 那么系统将检查该 url 而不是您的应用程序,因此 Facepile
div 看起来像这样:
the best way is to use facepile you need to add data-app-id and don't add data-href because if you will add data-href then system will check that url not your app so the facepile
div will look like this: