public IEnumerable <FbContact> GetUsersInfo(string ids) { Authenticate(); string call_id = GetNextCallNr(); Dictionary <string, string> requestParamsUserInfo = new Dictionary <string, string>(); requestParamsUserInfo.Add("method", "users.getinfo"); requestParamsUserInfo.Add("api_key", apiKey); requestParamsUserInfo.Add("session_key", sessionKey); requestParamsUserInfo.Add("call_id", call_id); requestParamsUserInfo.Add("v", "1.0"); requestParamsUserInfo.Add("uids", ids); requestParamsUserInfo.Add("fields", "name,last_name,first_name,pic_square"); XElement result = channel.GetUserInfo(apiKey, sessionKey, call_id, GenerateSignature(requestParamsUserInfo, sessionSecret), ids, "name,last_name,first_name,pic_square"); XNamespace ns = result.GetDefaultNamespace(); if (!IsError(result)) { foreach (XElement resultElement in result.Elements()) { FbContact contact = new FbContact(); try { contact.UserId = resultElement.Element(ns + "uid").Value; contact.Name = resultElement.Element(ns + "name").Value; contact.Lastname = resultElement.Element(ns + "last_name").Value; contact.Firstname = resultElement.Element(ns + "first_name").Value; contact.AvatarSquareUrl = resultElement.Element(ns + "pic_square").Value; } catch (NullReferenceException e) { Logger.Error("Unable to retreive contact details for contact. Uid = {0}", LogSource.Channel, resultElement.Value); continue; } yield return(contact); } } }
ChannelContact ParseFbContact(FbContact fbContact) { ChannelContact contact = new ChannelContact(); contact.Person.Firstname = fbContact.Firstname; contact.Person.Lastname = fbContact.Lastname; contact.Profile.ChannelProfileKey = fbContact.UserId; contact.Profile.ProfileType = ProfileType.Social; contact.Profile.SourceAddress = new SourceAddress(fbContact.UserId, contact.Person.Name); if (!String.IsNullOrEmpty(fbContact.AvatarSquareUrl.Trim())) { ChannelAvatar avatar = new ChannelAvatar(); avatar.Url = fbContact.AvatarSquareUrl; avatar.ContentStream = WebContentStreamHelper.GetContentStream(avatar.Url); contact.Profile.ChannelAvatar = avatar; } return(contact); }
public IEnumerable<FbContact> GetUsersInfo(string ids) { Authenticate(); string call_id = GetNextCallNr(); Dictionary<string, string> requestParamsUserInfo = new Dictionary<string, string>(); requestParamsUserInfo.Add("method", "users.getinfo"); requestParamsUserInfo.Add("api_key", apiKey); requestParamsUserInfo.Add("session_key", sessionKey); requestParamsUserInfo.Add("call_id", call_id); requestParamsUserInfo.Add("v", "1.0"); requestParamsUserInfo.Add("uids", ids); requestParamsUserInfo.Add("fields", "name,last_name,first_name,pic_square"); XElement result = channel.GetUserInfo(apiKey, sessionKey, call_id, GenerateSignature(requestParamsUserInfo, sessionSecret), ids, "name,last_name,first_name,pic_square"); XNamespace ns = result.GetDefaultNamespace(); if (!IsError(result)) { foreach (XElement resultElement in result.Elements()) { FbContact contact = new FbContact(); try { contact.UserId = resultElement.Element(ns + "uid").Value; contact.Name = resultElement.Element(ns + "name").Value; contact.Lastname = resultElement.Element(ns + "last_name").Value; contact.Firstname = resultElement.Element(ns + "first_name").Value; contact.AvatarSquareUrl = resultElement.Element(ns + "pic_square").Value; } catch (NullReferenceException e) { Logger.Error("Unable to retreive contact details for contact. Uid = {0}", LogSource.Channel, resultElement.Value); continue; } yield return contact; } } }
ChannelContact ParseFbContact(FbContact fbContact) { ChannelContact contact = new ChannelContact(); contact.Person.Firstname = fbContact.Firstname; contact.Person.Lastname = fbContact.Lastname; contact.Profile.ChannelProfileKey = fbContact.UserId; contact.Profile.ProfileType = ProfileType.Social; contact.Profile.SourceAddress = new SourceAddress(fbContact.UserId, contact.Person.Name); if (!String.IsNullOrEmpty(fbContact.AvatarSquareUrl.Trim())) { ChannelAvatar avatar = new ChannelAvatar(); avatar.Url = fbContact.AvatarSquareUrl; avatar.ContentStream = WebContentStreamHelper.GetContentStream(avatar.Url); contact.Profile.ChannelAvatar = avatar; } return contact; }