FB C#SDK GetTaskASYNC

时间:2012-10-19 13:24:30

标签: facebook-c#-sdk

有没有人为客户端提供FB C#SDK的任何示例.GetTaskAsync?

任何指向这个例子的指针都会很棒。

1 个答案:

答案 0 :(得分:4)

结帐https://github.com/facebook-csharp-sdk/facebook-windows8-sample

private async void GraphApiAsyncDynamicExample()
{
    try
    {
        var fb = new FacebookClient("access_token");
        dynamic result = await fb.GetTaskAsync("me");

        // You can either access it this way, using the .
        dynamic id = result.id;
        dynamic name = result.name;

        // if dynamic you don't need to cast explicitly.
        ProfileName.Text = "Hi " + name;

        // or using the indexer
        dynamic firstName = result["first_name"];
        dynamic lastName = result["last_name"];

        // checking if property exist
        var localeExists = result.ContainsKey("locale");

        // you can also cast it to IDictionary<string,object> and then check
        var dictionary = (IDictionary<string, object>)result;
        localeExists = dictionary.ContainsKey("locale");
    }
    catch (FacebookApiException ex)
    {
        // handle error
    }
}