/*Retrieve a twitt user from a given screen name, see https://dev.twitter.com/docs/api/1/get/users/show*/ public static TwittUser GetTwittUser(string screenName) { OAuthTokens tokens = new OAuthTokens(); tokens.ConsumerKey = "Removed from github example"; tokens.ConsumerSecret = "Removed from github example"; tokens.AccessToken = "Removed from github example"; tokens.AccessTokenSecret = "Removed from github example"; var list = new List<string>(); LookupUsersOptions options = new LookupUsersOptions(){UseSSL = true, APIBaseAddress="http://api.twitter.com/1.1/"}; options.ScreenNames.Add(screenName); TwitterResponse<TwitterUserCollection> res = TwitterUser.Lookup(tokens, options); TwitterUserCollection users = res.ResponseObject; TwitterUser user = users.First(); if (user == null) return null; TwittUser tu = new TwittUser( user.Id.ToString(), user.Name, user.ScreenName, user.Location, user.Description); return tu; }
private static TwitterUser GetUserInfo() { var lookupOptions = new LookupUsersOptions(); lookupOptions.UserIds.Add(Settings.Default.UserId); lookupOptions.UseSSL = true; var userInfo = TwitterUser.Lookup(_tokens, lookupOptions); return userInfo.ResponseObject.First(); }
// Read all followers from an specific user. Suposing the twitter api will return a string, that the kind of object it will send public string GetResponse(RepositoryOptions options) { var twitterIDCollection = new TwitterIdCollection(options.userList.ids); var opt = new LookupUsersOptions(); opt.UserIds = twitterIDCollection; var response = TwitterUser.Lookup(GenerateAuthentication(), opt); return response.Content; }
public void LookupUsers() { OAuthTokens tokens = Configuration.GetTokens(); LookupUsersOptions options = new LookupUsersOptions(); options.ScreenNames.Add("twitterapi"); options.ScreenNames.Add("digitallyborn"); options.ScreenNames.Add("trixtur"); options.ScreenNames.Add("twit_er_izer"); var result = TwitterUser.Lookup(tokens, options); Assert.IsTrue(result.Result == RequestResult.Success, result.ErrorMessage); Assert.IsNotNull(result.ResponseObject, result.ErrorMessage); }
/// <summary> /// Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> /// <param name="timeout">The timeout.</param> /// <param name="function">The function.</param> /// <returns></returns> public static IAsyncResult Lookup(OAuthTokens tokens, LookupUsersOptions options, TimeSpan timeout, Action<TwitterAsyncResponse<TwitterUserCollection>> function) { Func<OAuthTokens, LookupUsersOptions, TwitterResponse<TwitterUserCollection>> methodToCall = TwitterUser.Lookup; return methodToCall.BeginInvoke( tokens, options, result => { result.AsyncWaitHandle.WaitOne(timeout); try { function(methodToCall.EndInvoke(result).ToAsyncResponse()); } catch (Exception ex) { function(new TwitterAsyncResponse<TwitterUserCollection>() { Result = RequestResult.Unknown, ExceptionThrown = ex }); } }, null); }
/// <summary> /// Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> /// <returns></returns> public static async Task<TwitterResponse<TwitterUserCollection>> LookupAsync(OAuthTokens tokens, LookupUsersOptions options) { return await Core.CommandPerformer.PerformAction(new Commands.LookupUsersCommand(tokens, options)); }
/// <summary> /// Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> /// <returns></returns> public static TwitterResponse<TwitterUserCollection> Lookup(OAuthTokens tokens, LookupUsersOptions options) { Commands.LookupUsersCommand command = new Commands.LookupUsersCommand(tokens, options); return Core.CommandPerformer.PerformAction(command); }
private static IEnumerable<TwitterUser> GetMutualFriends(OAuthTokens tokens) { var friends = TwitterFriendship.FriendsIds(tokens); var followers = TwitterFriendship.FollowersIds(tokens); var userIds = (from friendId in friends.ResponseObject join followerId in followers.ResponseObject on friendId equals followerId select friendId).ToArray(); var lookupOptions = new LookupUsersOptions(); var users = new List<TwitterUser>(); for (int i = 0; i < userIds.Length; i ++) { lookupOptions.UserIds.Add(userIds[i]); if (lookupOptions.UserIds.Count() >= 100 || i + 1 == userIds.Length) { users.AddRange(TwitterUser.Lookup(tokens, lookupOptions).ResponseObject); lookupOptions.UserIds.Clear(); } } return users; }
/// <summary> /// Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> /// <returns></returns> public static TwitterResponse <TwitterUserCollection> Lookup(OAuthTokens tokens, LookupUsersOptions options) { Commands.LookupUsersCommand command = new Commands.LookupUsersCommand(tokens, options); return(Core.CommandPerformer.PerformAction(command)); }
/// <summary> /// Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> /// <param name="timeout">The timeout.</param> /// <param name="function">The function.</param> /// <returns></returns> public static IAsyncResult Lookup(OAuthTokens tokens, LookupUsersOptions options, TimeSpan timeout, Action<TwitterAsyncResponse<TwitterUserCollection>> function) { return AsyncUtility.ExecuteAsyncMethod(tokens, options, timeout, TwitterUser.Lookup, function); }
/// <summary> /// Dohvaća pratitelje trenutnog korisnika /// </summary> /// <param name="AccessToken"> /// Access token povezan sa računom trenutnog korisnika /// </param> /// <returns>Lista profila pratitelja trenutnog korisnika</returns> public static List<TwitterUserProfile> GetFollowers(TwitterTokens AccessToken) { TwitterResponse<UserIdCollection> followersResponse = TwitterFriendship.FollowersIds( convertTwitterToOAuthToken(AccessToken)); if (followersResponse.Result == RequestResult.Success) { List<TwitterUserProfile> followers = new List<TwitterUserProfile>(); LookupUsersOptions lookupOptions = new LookupUsersOptions(); // Loop through all of the follower user ids for (int index = 0; index < followersResponse.ResponseObject.Count; index++) { // We can only look up 100 users at a time if ((index % 100 == 0) && (index != 0)) { getAndConvertPartialUserList(AccessToken, followers, lookupOptions); // Clear the lookup user ids lookupOptions.UserIds.Clear(); } lookupOptions.UserIds.Add( followersResponse.ResponseObject[index]); } if (lookupOptions.UserIds.Count > 0) getAndConvertPartialUserList(AccessToken, followers, lookupOptions); return followers; } else { throw new Exception(followersResponse.ErrorMessage); } }
private static void getAndConvertPartialUserList(TwitterTokens AccessToken, List<TwitterUserProfile> followers, LookupUsersOptions lookupOptions) { TwitterResponse<TwitterUserCollection> userLookupResponse = TwitterUser.Lookup(convertTwitterToOAuthToken(AccessToken), lookupOptions); if (userLookupResponse.Result == RequestResult.Success) { foreach (TwitterUser user in userLookupResponse.ResponseObject) { followers.Add(new TwitterUserProfile() { Description = user.Description, Id = user.Id, Language = user.Language, Location = user.Location, Name = user.Name, NumberOfFriends = user.NumberOfFriends, NumberOfStatuses = user.NumberOfStatuses, ProfileImageLocation = user.ProfileImageLocation, ProfileSecureImageLocation = user.ProfileImageSecureLocation, ScreenName = user.ScreenName, Status = user.Status.Text, Website = user.Website }); } } }
/// <summary> /// Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> /// <returns></returns> public static async Task <TwitterResponse <TwitterUserCollection> > LookupAsync(OAuthTokens tokens, LookupUsersOptions options) { return(await Core.CommandPerformer.PerformAction(new Commands.LookupUsersCommand(tokens, options))); }
/// <summary> /// Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> /// <param name="timeout">The timeout.</param> /// <param name="function">The function.</param> /// <returns></returns> public static IAsyncResult Lookup(OAuthTokens tokens, LookupUsersOptions options, TimeSpan timeout, Action <TwitterAsyncResponse <TwitterUserCollection> > function) { return(AsyncUtility.ExecuteAsyncMethod(tokens, options, timeout, TwitterUser.Lookup, function)); }