facebook API获取供稿

时间:2013-10-31 00:18:27

标签: facebook

你好我在opengraph工作了一段时间,但有些事情一直困扰着我。

我无法从Feed中的每个人那里得到消息

  "data": [
    {
      "id": "984656456_1111111", 
      "from": {
        "name": "Xxx Some  Name", 
        "id": "478975485"
      }, 
      "message": "test", 
      "picture": "https://somepictureSomewhere.jpg", 
      "link": "https://www.facebook.com/photo.php?fbid=10151943257604861&set=p.101519&type=1&relevant_count=1", 
      "icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif", 
      "actions": [
        {
          "name": "Comment", 
          "link": "https://www.facebook.com/589884/posts/10151943984861"
        }
      ], 
      "privacy": {
        "value": ""
      }, 
      "type": "photo", 
      "status_type": "added_photos", 
      "object_id": "1015194324861", 
      "created_time": "2013-10-24T12:54:43+0000", 
      "updated_time": "2013-10-24T12:54:43+0000"
    }
  ], 
  "paging": {
    "previous": "https://graph.facebook.com/58980/feed?limit=25&since=1382619283", 
    "next": "https://graph.facebook.com/58988/feed?limit=25&until=1382619282"
  }
}

这是我的代码, 我收到以下错误:runtimeBinder异常与usersFeeds.message [i] unhandeled 虽然UsersFeeds.data [i] .from.name工作正常。

  FacebookClient fb = new FacebookClient(access_token);
                dynamic UsersFeeds = fb.Get("/me/posts");
                int teller = (int)Usersfriends.data.Count;
                for (int i = 0; i < 10; i++)
                {
                    lstUsersFriends.Items.Add(UsersFeeds.data[i].from.name);
                    lstUsersFriends.Items.Add(UsersFeeds.message[i]);
                }

1 个答案:

答案 0 :(得分:0)

你的迭代不应该基于计数吗?

FacebookClient fb = new FacebookClient(access_token);
dynamic UsersFeeds = fb.Get("/me/posts");
int teller = (int)Usersfriends.data.Count;
for (int i = 0; i < **teller**; i++)
{
    lstUsersFriends.Items.Add(UsersFeeds.data[i].from.name);
    lstUsersFriends.Items.Add(UsersFeeds.message[i]);
}