【发布时间】:2019-04-24 12:58:19
【问题描述】:
用户好友列表不返回仅包含好友总数的数据摘要。我正在开发一个 Web 应用程序,该应用程序将获取登录的用户 Facebook 好友列表,然后使用他们的生日在他们的个人资料中发布生日消息。
有没有办法可以邀请 Facebook 好友,然后访问用户好友列表,因为它是一个 Web 应用程序。
enter code here
private List<Person> GetPersonFriendList(string access_token,string id)
{
List<Person> friendList = new List<Person>();
string url;
#region JSON.Net Friends
//Friends URL
url = "https://graph.facebook.com/v3.2/" + id + "/taggable_friends?access_token=" + access_token;
JObject myFriends = JObject.Parse(requestFBData(url));
//string id = "";
//string name = "";
//Loop through the returned friends
foreach (var i in myFriends["data"].Children())
{
Person friend = new Person();
friend.id = i["id"].ToString().Replace("\"", "");
friend.name = i["name"].ToString().Replace("\"", "");
friendList.Add(friend);
}
return friendList;
#endregion
}
私有静态字符串 GetFacebookUserJSON(string access_token) { string url = string.Format("https://graph.facebook.com/me?access_token={0}&fields=email,name,first_name,last_name,link", access_token);
WebClient wc = new WebClient();
Stream data = wc.OpenRead(url);
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
data.Close();
reader.Close();
return s;
}
【问题讨论】:
-
“然后使用他们的生日在他们的个人资料中发布生日消息” - 这也不再可能了。你甚至不能再通过 API 发布到用户自己的私人时间线,而且很长时间以来都无法发布到其他人的时间线。另外,您不应该创建仅复制 Facebook 功能的应用程序......生日提醒以及“今天是 xy 的生日,在他们的时间线上发布”是他们已经提供的功能。忘掉这个应用概念吧,一开始就很糟糕。
标签: c# facebook-graph-api facebook-friends