Reputation: 129
Did anyone have any examples for FB C#SDK for client.GetTaskAsync?
Any pointers towards that example would be great.
Vishnu
Upvotes: 0
Views: 1646
Reputation: 7794
checkout 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
}
}
Upvotes: 4