使用Facebook API打印Facebook好友
我的最终目标是让我的网站能够使用 Facebook API 在屏幕上打印用户的(按字母顺序排列的)FB 好友(我已经做了这么多),然后让他们可以点击打印的名字,这样然后将其存储在我的网站上的列表中(例如“最喜欢的 Facebook 好友”)。
总之,我已经做到了,因此它可以按字母顺序打印出他们的朋友,因此从这里开始,我需要我的网站能够存储他们从列表中单击/选择的名称,以供下次使用。
到目前为止,我得到的是:
function populateFriendList(session){
FB.api('/me/friends', {fields: 'name', offset : 0, limit :5000 }, function(response) {
for (var i=0, l=response.data.length; i<l; i++){
var friend = response.data[i];
FbFriends[i]=friend.name
}
document.getElementById('myFriendList').innerHTML = FbFriends.sort().join('<br>');
FB.XFBML.parse(document.getElementById('myFriendList'));
});
};
我将永远感激任何帮助我的人!
My end goal is for my site to be able to use Facebook API to print a user's (alphabetized) FB friends out on the screen (I have already done this much) and then have it so they can click on a printed name so that it then stores it on a list on MY website ('Favorite Facebook friends', for example).
In summary, I already made it so it prints out their friends alphabetically, so from here I need my website to be able to store the names they click/choose from the list to be used at another time.
Here is what I have so far:
function populateFriendList(session){
FB.api('/me/friends', {fields: 'name', offset : 0, limit :5000 }, function(response) {
for (var i=0, l=response.data.length; i<l; i++){
var friend = response.data[i];
FbFriends[i]=friend.name
}
document.getElementById('myFriendList').innerHTML = FbFriends.sort().join('<br>');
FB.XFBML.parse(document.getElementById('myFriendList'));
});
};
I will be forever grateful to anyone who helps me with this!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已经创建了返回数据的代码。如果您想将该数据重新发送(即提供)给另一个用户,那么您需要将该数据存储在服务器端。
因此,您需要两件事:
1.)服务器端代码来接收现有 JS 代码生成的数据
2.)该数据存在的位置。这可能是由服务器端代码或数据库写入的文件。
因此,您可能会执行以下操作
1.) 获取用户列表
2.) 使用 Ajax 将该列表发送到服务器端代码
3.) 服务器端代码将该信息存储在数据库中
4.) 当需要时,服务器端代码检索无论您下次使用什么,列表和格式
我认为这个网站将是您开始了解此内容的好地方 蒂扎格Ajax 教程
您可以在此处找到有关如何将 JS 数组或列表转换为 UI 的示例 示例 1 和这里的示例 2
然后您可以发送这些选择的结果发送到您的服务器
You have created code that returns data. If you want to resend ( ie serve ) that data to another user then you need to store that data on the server side.
So you need two things :
1.) Server side code to receive the data that your existing JS code has generated
2.)A location for that data to exist. This could be files written by your server side code or a database.
So you might do something like this
1.) get your user list
2.) using Ajax send that list to server side code
3.) server side code stores that information in a data base
4.) when needed the server side code retrieves the list and formats for whatever your next use is
I think this site would be a good place for you to start learning about this Tizag Ajax Tutorial
You can find examples for how to transform JS arrays or list to UI here Example 1 and here Example 2
you could then send the result of those selections to your server