client.get(“me / statuses”)使用C#Facebook SDK 5.0.3返回空的“数据”数组

时间:2011-02-25 15:29:23

标签: c# asp.net facebook-graph-api facebook-c#-sdk

使用C#Facebook SDK 5.0.3一切正常,客户端工作正常。获取(“/ me”)。

但是在检索状态时,我应该根据facebook Graph API获取带有所有状态消息的arraylist“data”,但是我的数据数组是空的,并且我得到了“Index out of bounds”异常。

有谁知道我的问题是什么?

if (Request.Params["code"] != null)
            {

                var client = new FacebookClient(GetAccessToken());

                dynamic me = client.Get("/me");

                imgUser.ImageUrl = "https://graph.facebook.com/" + me.id + "/picture";
                lblUsername.Text = me.name;
                lblHometown.Text = me.hometown.name;
                lblBirthday.Text = me.birthday;
                lblCurrenttown.Text = me.location.name;
                lblEmail.Text = me.email;
                lblOpleidingen.Text = "";
                lblOpleidingen.Text += me.education[1].type + ": " + me.education[1].school.name + ", " + me.education[1].year.name + "<br />"
                    + me.education[0].type + ": " + me.education[0].school.name + ", " + me.education[0].year.name;
                lblSex.Text = me.gender;

                dynamic status = client.get("/me/statuses");

                txtStatus.Text = status.data[0].message;
            }

1 个答案:

答案 0 :(得分:2)

它需要read_stream权限。确保你拥有它。

您的权限数组应如下所示:

string[] extendedPermissions = new[] { "user_about_me", "read_stream" };

            if (extendedPermissions != null && extendedPermissions.Length > 0)
            {
                var scope = new StringBuilder();
                scope.Append(string.Join(",", extendedPermissions));
                parameters["scope"] = scope.ToString();
            }

此外,你的第二个get()应该大写:Get()

dynamic status = client.get("/me/statuses");

dynamic status = client.Get("/me/statuses");