繁体   English   中英

使用图形API从Asp.net C#访问Facebook好友列表

[英]Access facebook friendlist from Asp.net C# using graph API

用户好友列表不返回仅包含好友总数的数据摘要。 我正在使用一个Web应用程序,该应用程序将获取登录的用户脸书朋友列表,然后使用其生日在其个人资料中发布生日消息。

有没有一种方法可以邀请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){字符串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;
    }

不推荐使用taggable_friendshttps : //developers.facebook.com/docs/graph-api/reference/user/taggable_friends/

该边缘于2018年4月4日弃用,现在返回空数据集。

无法再访问整个/me/friends列表,您也只能使用/me/friends来获得授权您的应用程序的用户列表。


...使用他们的生日在他们的个人资料中发布生日消息

一位朋友需要为此使用user_birthday权限授权您的应用。 经验法则:未经用户明确授权/许可,绝对不会有任何数据。

此外,由于很长的时间而且可能会成为垃圾邮件,因此无法在其他用户的墙上张贴-无论如何,您都不能自动张贴或预填充。 最后但并非最不重要的一点是,您甚至不能再张贴到自己的墙上,因为publish_actions也已弃用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM