开发者

Accessing properties of a dynamic object returned by facebook sdk api

I'm fetching some data from FB using the following code:

    dynamic parameters = new ExpandoObject();
    parameters.i开发者_运维知识库ds = "me";
    parameters.fields = "friends";
    dynamic result = fbApp.Api(parameters);

    foreach (dynamic item in result)
    {
        Response.Write("<h1>" + item.name + "</h1>");
    }

This code fails, apparently the property name cannot be accessed, here's the error:

'System.Collections.Generic.KeyValuePair<string,object>' does not contain a definition for 'name'

What i'm doing wrong when accessing the properties? Isn't this the correct way to do so?

The query returns the info i want, just can't access it. Query in the browser is returning:

{
   "data": [
      {
         "name": "John Doe 1 ",
         "id": "123456789"
      },
      {
         "name": "John Doe 1 ",
         "id": "123456789"
      },
      {
         "name": "John Doe 1 ",
         "id": "123456789"
      }
   ]
}

Any help will be appreciated!

TIA!


It's a key value pair sto try item.Value!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜