public FbUser GetFacebookUserInfo(string token, string fbUserId) { FacebookClient client = new FacebookClient(token); string url = "/" + fbUserId + "?fields=id,name,link,picture"; try { dynamic result = client.Get(url); var me = new FbUser { id = result.id, name = result.name, link = result.link }; if (result.picture != null && result.picture.data != null) { if (result.picture.data.url != null) { me.pic = result.picture.data.url; } } if (result.email != null) { me.email = result.email; } return(me); } catch (Exception ex) { Logger.Error($"Get user info from facebook failed.token={token},url={url}", ex); throw ex; } }
public async Task <FbUser> GetMe(string token) { FacebookClient client = new FacebookClient(token); string url = "/me?fields=id,name,link,picture"; dynamic result = await client.GetTaskAsync(url); var me = new FbUser { id = result.id, name = result.name, link = result.link }; if (result.picture != null && result.picture.data != null) { if (result.picture.data.url != null) { me.pic = result.picture.data.url; } } return(me); }
public async Task <FbUser> GetUserInfo(string token, string fbUserId) { FacebookClient client = new FacebookClient(token); string url = "/" + fbUserId + "?fields=id,name,link,picture"; try { dynamic result = await client.GetTaskAsync(url); var me = new FbUser { id = result.id, name = result.name, link = result.link }; if (result.picture != null && result.picture.data != null) { if (result.picture.data.url != null) { me.pic = result.picture.data.url; } } return(me); } catch (Exception ex) { Logger.Error($"Get user info from facebook failed.token={token},url={url}", ex); throw ex; } //if (userInfo.picture != null && userInfo.picture.data.url != null) //{ // user.Avatar = userInfo.picture.data.url; //} }