C# Xamarin.Forms:无法获取名称和配置文件图片URL
我这里有代码: 我用的方法是:C# Xamarin.Forms:无法获取名称和配置文件图片URL,c#,xamarin.android,facebook-android-sdk,xamarin.forms,C#,Xamarin.android,Facebook Android Sdk,Xamarin.forms,我这里有代码: 我用的方法是: void GetMyInfo(string token) { FacebookClient fb = new FacebookClient(token); string details= null ; try { fb.GetTaskAsync("me").ContinueWith(t => { if (!t.IsFaulted) {
void GetMyInfo(string token)
{
FacebookClient fb = new FacebookClient(token);
string details= null ;
try
{
fb.GetTaskAsync("me").ContinueWith(t =>
{
if (!t.IsFaulted)
{
var result = (IDictionary<string, object>)t.Result;
details= string.Format("Your name is: {0} {1} and your Facebook profile Url is: {3}",
(string)result["first_name"], (string)result["last_name"],
(string)result["link"]);
}
});
}
catch(Java.Lang.Exception e)
{
string message = e.Message;
}
}
但是详细信息字符串为空。当我中断并调试时,它说ContinueWith是未知标识符,但没有捕获异常。要在那里标记它不是空的。我尝试了以下内容,而不是您所写的内容:
string result = t.Result.ToString();
Console.WriteLine("{0}", (string)result["first_name"]);
我希望这会有帮助。
诚恳