public IEnumerable<TwitterStatus> GetFavorites() { var service = new TwitterService(Config.Twitter.ConsumerKey, Config.Twitter.ConsumerSecret); // Step 1 - Retrieve an OAuth Request Token var requestToken = service.GetRequestToken(); // Step 2 - Redirect to the OAuth Authorization URL var uri = service.GetAuthorizationUri(requestToken); Process.Start(uri.ToString()); // Step 3 - Exchange the Request Token for an Access Token Console.Write("Please, your key? "); var verifier = Console.ReadLine(); // <-- This is input into your application by your user var access = service.GetAccessToken(requestToken, verifier); // Step 4 - User authenticates using the Access Token service.AuthenticateWith(access.Token, access.TokenSecret); var users = service.SearchForUser("kellogh"); if (users == null) { Console.WriteLine("No users found"); yield break; } var user = users.First(); var favorites = service.ListFavoriteTweetsFor(user.Id); foreach (var tweet in favorites) { yield return tweet; } }
public HttpResponseMessage Post([FromUri]int Id, [FromUri]bool ArtistPost) { Proposal currProposal = _db.Proposal.FirstOrDefault(c=>c.Id == Id); Models.Service service = _db.User.FirstOrDefault(c => c.UserId == WebSecurity.CurrentUserId).Services.FirstOrDefault(c=>c.Provider == "twitter"); if (service != null) { TwitterService twitter = new TwitterService(Settings.Settings.TwitterConsumerKey, Settings.Settings.TwitterConsumerSecret, service.Token, service.TokenSecret); try { if (ArtistPost == true) { //string message = "test message"; var result = twitter.SearchForUser(currProposal.Artist).ToList(); string message = "@" + result[0].Name.Replace(" ",string.Empty) + " It was suggested tha you play an event at " + currProposal.Venue + " for more info go to www.botf.azurewebsites.net"; twitter.SendTweet(message); } else { string message = "just suggested the event " + "->" + currProposal.Artist + "<-" + " at " + "->" + currProposal.Venue + "<-" + "." + " Like this? Get on board! at " + System.Web.HttpContext.Current.Request.UrlReferrer.ToString(); twitter.SendTweet(message); } return Request.CreateResponse(HttpStatusCode.OK); } catch (Exception) { return Request.CreateResponse(HttpStatusCode.Conflict); } } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }