public LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params)
        {
            var twitterService = new TwitterService(KeyStorage.Get("twitterKey"), KeyStorage.Get("twitterSecret"));

            if (String.IsNullOrEmpty(context.Request["oauth_token"]) ||
                String.IsNullOrEmpty(context.Request["oauth_verifier"]))
            {
                var requestToken = twitterService.GetRequestToken(context.Request.Url.AbsoluteUri);

                var uri = twitterService.GetAuthorizationUri(requestToken);

                context.Response.Redirect(uri.ToString(), true);
            }
            else
            {
                var requestToken = new OAuthRequestToken { Token = context.Request["oauth_token"] };
                var accessToken = twitterService.GetAccessToken(requestToken, context.Request["oauth_verifier"]);
                twitterService.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);

                var user = twitterService.VerifyCredentials(new VerifyCredentialsOptions());

                return ProfileFromTwitter(user);
            }

            return new LoginProfile();

        }
        public bool GenerateAccess(string token)
        {
            TwitterToken = token;

            if (string.IsNullOrEmpty(TwitterAccess) || string.IsNullOrEmpty(TwitterAccessSecret))
            {
                OAuthAccessToken access = _service.GetAccessToken(_requestToken, TwitterToken);
                TwitterAccess       = access.Token;
                TwitterAccessSecret = access.TokenSecret;
            }

            _service.AuthenticateWith(TwitterAccess, TwitterAccessSecret);
            return(_service.Response.Error == null);
        }
Пример #3
0
        public SearchResultWithRateLimit Search(string query, long sinceid, TwitterApp keys)
        {
            var service = new TwitterService(keys.ConsumerKey, keys.ConsumerKeySecret);
            service.AuthenticateWith(keys.Token, keys.TokenSecret);
            var options = new SearchOptions
            {
                Q = System.Web.HttpUtility.UrlEncode(query),
                Count = 100,
                Lang = "en",
                Resulttype = TwitterSearchResultType.Mixed,
                SinceId = sinceid
            };

            // Geocode = new TwitterGeoLocationSearch(39.6456, -79.9433, 30, TwitterGeoLocationSearch.RadiusType.Mi),

            var result = new SearchResultWithRateLimit();
            result.SearchResult = service.Search(options);
            result.RateLimitStatus = service.Response.RateLimitStatus;
            if (result.SearchResult.Statuses.Any())
            {
                result.LastId = result.SearchResult.Statuses.OrderByDescending(f => f.Id).FirstOrDefault().Id;
            }
            else
            {
                result.LastId = sinceid;
            }

            return result;
        }
Пример #4
0
        public SearchResultWithRateLimit Search(string queryTerm, int resultType, long sinceId, TwitterApp keys)
        {
            SearchOptions options = new SearchOptions
            {
                Q = System.Web.HttpUtility.UrlEncode(queryTerm),
                Count = 100,
                Lang = "en",
                Resulttype = (TwitterSearchResultType)resultType,
                SinceId = sinceId
            };

            var service = new TwitterService(keys.ConsumerKey, keys.ConsumerKeySecret);
            service.AuthenticateWith(keys.Token, keys.TokenSecret);
            var result = new SearchResultWithRateLimit();
            result.SearchResult = service.Search(options);
            result.RateLimitStatus = service.Response.RateLimitStatus;
            if (result.SearchResult.Statuses.Any())
            {
                result.LastId = result.SearchResult.Statuses.OrderByDescending(f => f.Id).FirstOrDefault().Id;
            }
            else
            {
                result.LastId = options.SinceId.Value;
            }

            return result;
        }
Пример #5
0
        public async Task <IActionResult> Create([Bind("ID,GameID,Path,Content,Likes")] Article article)
        {
            if (ModelState.IsValid)
            {
                string key         = "QNm1VD6rhVk5uQO1lFE4xj3TK";
                string secret      = "wyrMxltWxebxRh0CpWpetfstsZvKCvtleQbM0ybuLkJ9pmIKlS";
                string token       = "392392197-2Tche78I2E0ambYnzoNTHlC58ohagMciJQ31uf33";
                string tokenSecret = "ODMVW5HsJho3te2XcSHdINGL3q0zPHR70PllOoOWUxq6O";

                var service = new TweetSharp.TwitterService(key, secret);
                service.AuthenticateWith(token, tokenSecret);

                var result = service.SendTweet(new SendTweetOptions
                {
                    Status = "Hey! Game Sense got a new Article for you gamers!\n come check it out!!"
                });


                _context.Add(article);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GameID"] = new SelectList(_context.Gamedb, "ID", "Name", article.GameID);
            return(View(article));
        }
Пример #6
0
        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;
            }
        }
Пример #7
0
        public IndexModule()
        {
            Get["/locations/{user}", true] = async (paramaters, ct) =>
                {
                    var service = new TwitterService(ConfigurationManager.AppSettings["TWITTER_CONSUMER_KEY"], ConfigurationManager.AppSettings["TWITTER_CONSUMER_SECRET"]);
                    service.AuthenticateWith(ConfigurationManager.AppSettings["TWITTER_ACCESS_TOKEN"], ConfigurationManager.AppSettings["TWITTER_ACCESS_TOKEN_SECRET"]);
                    string user = paramaters.user.ToString();
                    user.Replace("#", "");

                    var tweets = service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions()
                        {
                            ContributorDetails = true,
                            Count = 100,
                            ExcludeReplies = false,
                            IncludeRts = true,
                            ScreenName = user
                        }).ToList();

                    var tweetsWithLocations = tweets.Where(t => t.Location != null).ToList().OrderBy(t => t.CreatedDate);

                    return Response.AsJson(tweetsWithLocations.Select(t => new
                            {
                                LastTweet = t.TextAsHtml,
                                Location = t.Location,
                                Date =
                                      t.CreatedDate.ToShortDateString() + " " +
                                      t.CreatedDate.ToShortTimeString()
                            })).WithHeaders(new []
                            {
                                new { Header = "Access-Control-Allow-Origin", Value="*" }
                            });
                };
        }
Пример #8
0
        public Account ProcessAuthentication(string pin)
        {
            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);

            OAuthAccessToken access = service.GetAccessToken(_requestToken, pin);

            service.AuthenticateWith(access.Token, access.TokenSecret);

            var profile = service.GetUserProfile();

            Account account = AccountManager.Instance.GetCurrentAccounts().Where(acc => acc.Username == profile.ScreenName).FirstOrDefault();
            if (account != null)
            {
                throw new AuthFailureException("User " +account.Username +  " already has an account with TweetOBox.");
            }
            if (profile != null && account == null)
            {
                account = new Account();
                account.Username = profile.ScreenName;
               // account.Password = profile.p
                account.AccountType = (int)AccountTypeEnum.Twitter;
                account.AccessToken = access.Token;
                account.AccessTokenSecret = access.TokenSecret;
                account.IsOAuth = true;
                AccountManager.Instance.AddAccount(account,false);
            }
            else
            {
                throw new AuthFailureException(service.Response.StatusDescription);
            }

            return account;
        }
Пример #9
0
        public Tweeter()
        {
            var _consumerKey = "J9iaXHK7R0bpKiRabxQ";
            var _consumerSecret = "Xs6XJggEvXtMVDvaYAvTLnIm13G70ymcdhwQ3J1M";

            // this authentication snippet borrowed from https://github.com/danielcrenna/tweetsharp

            service = new TwitterService(_consumerKey, _consumerSecret);

            // Step 1 - Retrieve an OAuth Request Token
            OAuthRequestToken requestToken = service.GetRequestToken();

            // Step 2 - Redirect to the OAuth Authorization URL
            // Uri uri = service.GetAuthorizationUri(requestToken);
            // Process.Start(uri.ToString());

            // Step 3 - Exchange the Request Token for an Access Token

            // OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);
            // OAuthAccessToken generated manually through dev.twitter.com so no need for this bit since it's just me tweetin ma shit

            var access = new OAuthAccessToken();
            access.Token = "1196853272-YbSEB0Mnaj6lK3tOKGQ8nwOVLnfhXldwqjlzNmk";
            access.TokenSecret = "4BHhe3iUdlh6o2Re0OmMq3v6e8OwH9vw149MEPR3I";

            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith(access.Token, access.TokenSecret);
            // service.SendTweet(new SendTweetOptions { Status = "Hello World" });
        }
Пример #10
0
        public static void GetUserToken(TwitterService service)
        {
            // Step 1 - Retrieve an OAuth Request Token
            OAuthRequestToken requestToken = service.GetRequestToken();

            // Step 2 - Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthorizationUri(requestToken);

            Console.WriteLine("Enter this uri into a browser:\n{0}", uri.ToString());

            Console.WriteLine("Enter the pin given by twitter");

            // Step 3 - Exchange the Request Token for an Access Token
            string verifier = Console.ReadLine(); // <-- This is input into your application by your user
            OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);

            if(access == null)
            {
                Console.WriteLine("no tokens returned");
                return;
            }

            Console.WriteLine("Access Token:\n{0}", access.Token);
            Console.WriteLine("Access Secret:\n{0}", access.TokenSecret);

            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith(access.Token, access.TokenSecret);
        }
Пример #11
0
        public static void SendTweet()
        {
            GetPixelImageFile();

            string key         = ConfigurationSettings.AppSettings.Get("twitterConsumerKey");
            string secret      = ConfigurationSettings.AppSettings.Get("twitterConsumerSecret");
            string token       = ConfigurationSettings.AppSettings.Get("twitterAccessToken");
            string tokenSecret = ConfigurationSettings.AppSettings.Get("twitterAccessTokenSecret");

            string message = "";


            var service = new TweetSharp.TwitterService(key, secret);

            service.AuthenticateWith(token, tokenSecret);
            using (var stream = new FileStream(@"C:\Images\Pixel.png", FileMode.Open))
            {
                var result = service.SendTweetWithMedia(new SendTweetWithMediaOptions
                {
                    Status = message,
                    Images = new Dictionary <string, Stream> {
                        { "john", stream }
                    }
                });
            }
        }
Пример #12
0
 public TwitterService GetAuthenticatedService()
 {
     var twitterClientInfo = new TwitterClientInfo {ConsumerKey = ConsumerKey, ConsumerSecret = ConsumerSecret};
     twitterService = new TwitterService(twitterClientInfo);
     twitterService.AuthenticateWith(AccessToken, AccessTokenSecret);
     return twitterService;
 }
Пример #13
0
        public static IReadOnlyCollection<PoliticalTweet> LoadTweets( IEnumerable<string> handles )
        {
            var service = new TwitterService( ConsumerKey, ConsumerSecret );
            service.AuthenticateWith( AccessToken, AccessTokenSecret );
            var results = new List<PoliticalTweet>();

            foreach ( var handle in handles.Distinct() )
            {
                try
                {
                    var response = service.ListTweetsOnUserTimeline( new ListTweetsOnUserTimelineOptions
                    {
                        ScreenName = handle,
                        Count = 200,
                        IncludeRts = false,
                        ExcludeReplies = true
                    } );
                    results.AddRange( response.Select( t => new PoliticalTweet( handle, t.Text, t.CreatedDate, t.IdStr ) ) );

                    Debug.WriteLine( $"{service.Response.RateLimitStatus.RemainingHits} remaining hits." );
                    if ( service.Response.RateLimitStatus.RemainingHits <= 0 )
                    {
                        var wait = service.Response.RateLimitStatus.ResetTime.ToUniversalTime() - DateTime.UtcNow;
                        Debug.WriteLine( $"Rate limit reached. Sleeping for {wait}." );
                        Thread.Sleep( wait );
                    }
                }
                catch
                {
                    Debug.WriteLine( $"Skipping {handle}" );
                }
            }

            return results;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            tweetsUserName = new List<PuzzleData>();
            TwitterService service = new TwitterService(consumerKey, consumerSecret);
            service.AuthenticateWith(accessToken, accessTokenSecret);

            var options = new SearchOptions { Q = "Brilliant @fredtrotter post about bitcoin, Wall Street, and cancer http://t.co/q9WZNA0cZR) Must read on \"malignant computation\"!", Count =30 };
            TwitterSearchResult tweets = service.Search(options);

            int i = 0;

            foreach (var tweet in tweets.Statuses)
            {
                authorUrl = tweet.RetweetedStatus.User.ProfileImageUrlHttps;
                if (authorUrl.Contains(".png") || authorUrl.Contains(".jpg") || authorUrl.Contains(".bmp"))
                {
                    authorUrl = authorUrl.Remove(authorUrl.Length - 11, 7);
                }
                else if (authorUrl.Contains(".jpeg"))
                {
                    authorUrl = authorUrl.Remove(authorUrl.Length - 12, 7);
                }
                i += 1;
                if (i > 10) break;

                tweetsUserName.Add(new PuzzleData() { followerCount = tweet.User.FollowersCount, profileImage = tweet.User.ProfileImageUrl, userId = tweet.User.Id });

            }
            tweetsUserName = tweetsUserName.OrderByDescending(x => x.followerCount).ToList();
        }
Пример #15
0
        static void Main(string[] args)
        {
            var _consumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"].ToString();
            var _consumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"].ToString();

            // configure access token
            //var _accessToken = ConfigurationManager.AppSettings["twitterAccess"].ToString();
            //var _accessTokenSecret = ConfigurationManager.AppSettings["twitterAccessSecret"].ToString();

            service = new TwitterService(_consumerKey, _consumerSecret);

            // Step 1 - Retrieve an OAuth Request Token
            OAuthRequestToken requestToken = service.GetRequestToken();

            // Step 2 - Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthorizationUri(requestToken);
            Process.Start(uri.ToString());

            // Step 3 - Exchange the Request Token for an Access Token
            string verifier = "123456"; // <-- This is input into your application by your user
            OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);

            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith(access.Token, access.TokenSecret);

            //service.AuthenticateWith(_accessToken, _accessTokenSecret);

            //SendATweet();
            //GeoLocationLookup();
            ListFollowers();

            Console.ReadKey();
        }
 private static TwitterService GetAuthenticatedService()
 {
     var service = new TwitterService(_consumerKey, _consumerSecret);
     service.TraceEnabled = true;
     service.AuthenticateWith(_accessToken, _accessTokenSecret);
     return service;
 }
Пример #17
0
        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            if (img_bool == true && twit_pic == "")
            {
                MessageBox.Show("Image upload in progress. please wait.", "Sorry", MessageBoxButton.OK);
                return;
            }

            if (WatermarkTB.Text == emptystr)
            {
                MessageBox.Show("Please input your mind :)", "Sorry", MessageBoxButton.OK);
                return;
            }

            TwitterService service = new TwitterService("g8F2KdKH40gGp9BXemw13Q", "OyFRFsI05agcJtURtLv8lpYbYRwZAIL5gr5xQNPW0Q");
            service.AuthenticateWith((string)settings["twitter_token"], (string)settings["twitter_tokensecret"]);
            string tweet = WatermarkTB.Text;
            if (img_bool == true)
                tweet += " " + twit_pic;

            service.SendTweet(tweet,
                (tweets, response) =>
                {

                });
            MessageBox.Show("Share successfully.", "Thanks", MessageBoxButton.OK);
            this.NavigationService.GoBack();
        }
Пример #18
0
        public void SendTweet(IEnumerable <SpotifyTrack> tracks)
        {
            var service = new TweetSharp.TwitterService(ConsumerKey, ConsumerSecretKey);

            service.AuthenticateWith(TwitterToken, TwitterTokenSecret);

            var listOfTracks = new StringBuilder();

            foreach (var track in tracks)
            {
                track.Artist = track.Artist.Replace(",", "");
                track.Name   = track.Name.Replace(",", "");

                if (listOfTracks.Length > 140)
                {
                    service.SendTweet(new SendTweetOptions {
                        Status = $"@BBCR1 ,{listOfTracks}"
                    });
                    listOfTracks.Clear();
                    continue;
                }

                listOfTracks.Append(track.Artist);
                listOfTracks.Append("- ");
                listOfTracks.Append(track.Name);
                listOfTracks.Append(", ");
            }
        }
Пример #19
0
 public TwitterUser GetUser(LoginModel model)
 {
     var twitterService = new TweetSharp.TwitterService(ConsumerKey, ConsumerSecret);
     twitterService.AuthenticateWith(model.Token, model.Secret);
     TwitterUser user = twitterService.VerifyCredentials(new VerifyCredentialsOptions() { IncludeEntities = false, SkipStatus = false });
     return user;
 }
Пример #20
0
        /// 
        /// Uploads the photo and sends a new Tweet
        /// 
        /// <param name="binaryImageData">The binary image data.
        /// <param name="tweetMessage">The tweet message.
        /// <param name="filename">The filename.
        /// Return true, if the operation was succeded.
        public string UploadPhoto(string imageFile, string tpkey, string usrtoken, string usrsecret, string contoken, string consecret)
        {
            TwitterService service = new TwitterService(contoken, consecret);
            service.AuthenticateWith(usrtoken, usrsecret);

            Hammock.RestRequest request = service.PrepareEchoRequest();
            request.Path = "upload.xml";
            request.AddFile("media", "uploadfile", imageFile, "image/jpeg");
            request.AddField("key", tpkey);

            Hammock.RestClient client = new Hammock.RestClient() { Authority = "http://api.twitpic.com", VersionPath = "2" };
            Hammock.RestResponse response = client.Request(request);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                XDocument doc = XDocument.Parse(response.Content);

                XElement image = doc.Element("image");

                return image.Element("url").Value;
            }
            else
                throw new Exception("Error occured while uploading image to TwitPic servers. Please try again later");

            return "";
        }
Пример #21
0
        static void Main(string[] args)
        {
            TwangManSays("********************************************");
            TwangManSays("*             HANG THE TWANG               *");
            TwangManSays("********************************************");
            CurrentGames = new Dictionary<long, TwitterThread>();
            tweetsToSend = new ConcurrentQueue<SendArgs>();

           
            TwitterSender = new Task(DoWork);
            TwitterSender.Start();

            _sendService = new TwitterService(Authentication.ConsumerKey, Authentication.ConsumerSecret);
            _sendService.AuthenticateWith(Authentication.AccessToken, Authentication.AccessTokenSecret);

            _service = new TwitterService(Authentication.ConsumerKey, Authentication.ConsumerSecret);
            _service.AuthenticateWith(Authentication.AccessToken, Authentication.AccessTokenSecret);

            TwitterListener = new Task(Listen);
            TwitterListener.Start();


            Console.ReadLine();
            _service.CancelStreaming();
        }
Пример #22
0
        private void Connect(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret)
        {
            // In v1.1, all API calls require authentication
            var service = new TwitterService(consumerKey, consumerSecret);
            service.AuthenticateWith(accessToken, accessTokenSecret);

            Log("Connected");

            TwitterRateLimitStatusSummary rate = service.GetRateLimitStatus(new GetRateLimitStatusOptions());

            Log("Limimte rate: " + rate.RawSource);

            var tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
            foreach (var tweet in tweets)
            {
                Console.WriteLine("{0} says '{1}'", tweet.User.ScreenName, tweet.Text);
            }

            TwitterCursorList<TwitterUser> friends = service.ListFollowers(new ListFollowersOptions());

            Log("Friends: " + friends.Count);

            foreach (var friend in friends)
            {
                Log(String.Format("Friend: {0}", friend.Name));
            }
        }
Пример #23
0
 public TwitterApi()
 {
     _service = new TwitterServiceEntity(ConfigurationManager.AppSettings.Get("consumerKey"),
                                         ConfigurationManager.AppSettings.Get("consumerSecret"));
     _service.AuthenticateWith(ConfigurationManager.AppSettings.Get("token"),
                               ConfigurationManager.AppSettings.Get("tokenSecret"));
 }
Пример #24
0
 public TwitterWrapper()
 {
     Service = new TwitterService(ConfigurationManager.AppSettings["consumerAccessorA"], ConfigurationManager.AppSettings["consumerAccessorB"]);
     Service.AuthenticateWith(ConfigurationManager.AppSettings["authTokenA"], ConfigurationManager.AppSettings["authTokenB"]);
     // Ha. I hope you don't use your Twitter account for anything else, Ryan...
     Service.IncludeRetweets = true;
 }
Пример #25
0
        public List<TwitterFollower> getTwitterFollowerList()
        {
            List<TwitterFollower> twitterFollowerList = new List<TwitterFollower>();

            string _consumerKey = System.Configuration.ConfigurationManager.AppSettings["consumerKeyLogin"];
            string _consumerSecret = System.Configuration.ConfigurationManager.AppSettings["consumerSecretLogin"];
            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);

            if (!string.IsNullOrEmpty(Session[Sessionvars.TwitterRequestToken].ToString()))
            {

                service.AuthenticateWith(Session[Sessionvars.TwitterRequestToken].ToString(), Session[Sessionvars.TwitterRequestTokenSecert].ToString());

                TwitterUser user = service.VerifyCredentials();
                var followers = service.ListFollowers();

                foreach (var follower in followers)
                {
                    twitterFollowerList.Add(
                   new TwitterFollower
                   {
                       Id = follower.Id,
                       ScreenName = follower.ScreenName
                   });
                }

            }

            return twitterFollowerList;
        }
Пример #26
0
        public IQueryable<DisplayItem> GetSocialInfomation(string name)
        {
            IQueryable<DisplayItem> items = null;

            try
            {
                var twitterClientInfo = new TwitterClientInfo();
                twitterClientInfo.ConsumerKey = SettingsHelper.ConsumerKey;
                twitterClientInfo.ConsumerSecret = SettingsHelper.ConsumerSecret;

                var twitterService = new TwitterService(twitterClientInfo);
                twitterService.AuthenticateWith(SettingsHelper.AccessToken, SettingsHelper.AccessSecret);
                var searchOptions = new SearchOptions
                {
                    Q = name,
                };

                var searchResults = twitterService.Search(searchOptions);
                items = searchResults.Statuses.Select(x => ConvertToDataItem(x)).AsQueryable();
            }
            catch(Exception ex)
            {
                Logger.Error(ex);
            }

            return items;
        }
Пример #27
0
        /// <summary>
        /// Get Authenticated Service
        /// </summary>
        /// <returns>TwitterService</returns>
        private tweet.TwitterService GetAuthenticatedService()
        {
            var service = new tweet.TwitterService(_consumerKey, _consumerSecret);

            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            return(service);
        }
Пример #28
0
        public void CanUpdateStatus()
        {
            var service = new TwitterService(consumerKey, consumerSecret);
            service.AuthenticateWith(accessToken, accessTokenSecret);

            var tweet = service.SendTweet("@SocSnapTest " + DateTime.Now.ToLongTimeString() + " @SocSnapTest");
            Console.WriteLine(tweet.Text);
        }
Пример #29
0
        public override object GetFieldValue(string fieldValue, SitecoreFieldConfiguration config, SitecoreDataMappingContext context)
        {
            var settings = context.Service.GetItem<TwitterSettings>(TweetCommand.SettingsPath);
            TwitterService twitterService = new TwitterService(settings.ConsumerKey, settings.ConsumerSecret);
            twitterService.AuthenticateWith(settings.AccessToken, settings.AccessTokenSecret);

            return twitterService.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions() { ScreenName = fieldValue });
        }
        public TwitterFeedService Create(string consumerKey, string consumerSecret,
            string accessToken, string accessTokenSecret)
        {
            var twitterService = new TwitterService(consumerKey, consumerSecret);
            twitterService.AuthenticateWith(accessToken, accessTokenSecret);

            return new TwitterFeedService(twitterService);
        }
Пример #31
0
        public MainPage()
        {
            InitializeComponent();
            message = messageResult;
            var service1 = new TwitterService("6V1TS5zCiVwkQxUDODCdHA24a", "hAxb6eEht6TMVxFoXT8aOz65UY4CNCQzrwVV1UvKvJBBE9qO6o");
            service1.AuthenticateWith("3004303633-XafkiZvVq8KTfk0hPusedUwPSQsjiE9c49D4WRZ", "Rjg811qZJnZDaAY9ncdHKxz0ZpuUJNvPtkxinXqv43Qiq");

            service1.Search(new SearchOptions { Q = "#OpenHack2015" }, message);
        }
Пример #32
0
 private static TwitterService CreateTwitterService(TwitterCredentials credentials)
 {
     var service = new TwitterService(credentials.ConsumerKey, credentials.ConsumerSecret);
     if (!string.IsNullOrEmpty(credentials.AccessToken) || !string.IsNullOrEmpty(credentials.AccessTokenSecret))
     {
         service.AuthenticateWith(credentials.AccessToken, credentials.AccessTokenSecret);
     }
     return service;
 }
Пример #33
0
 public GameThread(IHubContext context)
 {
     _random = new Random();
     IsStarted = false;
     _hub = context;
     this.Game = new Game(Guid.NewGuid().ToString());
     _service = new TwitterService("vCBYBvYAdRrgWs5z0zmD1A", "eHqhut7IVR4aUWlgBwuURl3QssL7ASf7hNIi3AovjY");
     _service.AuthenticateWith("68329856-dHYH7dgh85Qkiv7vaNjoScNDTngJtNrjdH8JCLcvt", "KFtWesqC94jxkgSVYrpMlg4IKIcitmJF7MQW0b5Q");
 }
Пример #34
0
        private static TwitterService InitializeTwitterService()
        {
            ReadSettigs();

            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            return service;
        }
Пример #35
0
        public Lapor()
        {
            this.InitializeComponent();

            //TwitterService tweetservice = new TwitterService("SEuJKVyiLrpntSmX76mLLK5rV", "2oLc3FgsOC1heh6vyiKlBXDWKnLo2dO9UAgHDxgS6WPnwbh2Rq");
            
            TwitterService service = new TwitterService("SEuJKVyiLrpntSmX76mLLK5rV", "2oLc3FgsOC1heh6vyiKlBXDWKnLo2dO9UAgHDxgS6WPnwbh2Rq");
            service.AuthenticateWith("197426566-jB7G6TbKGPVHS84rQ2LezVyZp2WJxR5kabaR5sHN", "ntb1049lvRbdX0k5aZkxlWeEvbAZtZm35ekazZnlwBj05");
            //TwitterStatus result = service.SendTweet(new SendTweetOptions
            //{
            //    Status = "Hello, world!"
            //});

            //TwitterClientInfo twitterClientInfo = new TwitterClientInfo();
            //twitterClientInfo.ConsumerKey = "SEuJKVyiLrpntSmX76mLLK5rV"; 
            //twitterClientInfo.ConsumerSecret = "2oLc3FgsOC1heh6vyiKlBXDWKnLo2dO9UAgHDxgS6WPnwbh2Rq";

            //TwitterService twitterService = new TwitterService(twitterClientInfo);

            //if (string.IsNullOrEmpty("197426566-jB7G6TbKGPVHS84rQ2LezVyZp2WJxR5kabaR5sHN") || string.IsNullOrEmpty("ntb1049lvRbdX0k5aZkxlWeEvbAZtZm35ekazZnlwBj05"))
            //{
            //    //Now we need the Token and TokenSecret

            //    //Firstly we need the RequestToken and the AuthorisationUrl
            //    OAuthRequestToken requestToken = twitterService.GetRequestToken();
            //    string authUrl = twitterService.GetAuthorizationUri(requestToken).ToString();

            //    //authUrl is just a URL we can open IE and paste it in if we want
            //    var dialog = new MessageDialog("Please Allow This App to send Tweets on your behalf").ShowAsync();
            //    //Process.Start(authUrl); //Launches a browser that'll go to the AuthUrl.

            //    //Allow the App
            //    //Console.WriteLine("Enter the PIN from the Browser:");
            //    //string pin = Console.ReadLine();

            //    OAuthAccessToken accessToken = twitterService.GetAccessToken(requestToken, pin);

            //    string token = accessToken.Token; //Attach the Debugger and put a break point here
            //    string tokenSecret = accessToken.TokenSecret; //And another Breakpoint here

            //    Console.WriteLine("Write Down The AccessToken: " + token);
            //    Console.WriteLine("Write Down the AccessTokenSecret: " + tokenSecret);
            //}

            //twitterService.AuthenticateWith(AccessToken, AccessTokenSecret);

            //Console.WriteLine("Enter a Tweet");
            //string tweetMessage;
            //tweetMessage = Console.ReadLine();
            //TwitterStatus twitterStatus = twitterService.SendTweet(tweetMessage);


            this.navigationHelper = new NavigationHelper(this);
            this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
            this.navigationHelper.SaveState += this.NavigationHelper_SaveState;
        }
        private void NotifyUserOnTwitter(ChatMessage message, User user, TwitterUser u)
        {
            TweetSharp.TwitterService svc = new TwitterService(GetClientInfo());
            svc.AuthenticateWith(ConfigurationManager.AppSettings["User.Token"],
                ConfigurationManager.AppSettings["User.TokenSecret"]);
            svc.SendTweet(String.Format(_tweetFormat,
                u.ScreenName,
                String.IsNullOrEmpty(user.TwitterUserName) ? user.JabbrUserName : user.TwitterUserName, message.Room));

        }
Пример #37
0
        public TwitterService()
        {
            string comsumerKey       = ConfigurationManager.AppSettings["TwitterComsumerKey"];
            string comsumerSecret    = ConfigurationManager.AppSettings["TwitterComsumerSecret"];
            string accessToken       = ConfigurationManager.AppSettings["TwitterAccessToken"];
            string accessTokenSecret = ConfigurationManager.AppSettings["TwitterAccessTokenSecret"];

            _service = new TweetSharp.TwitterService(comsumerKey, comsumerSecret);
            _service.AuthenticateWith(accessToken, accessTokenSecret);
        }
Пример #38
0
        public string Retweet(string userName, string Nick, long id)
        {
            var twitterSecret = new Social_media_access.Models.TwitterSecretData(userName, Nick);
            var service       = new TweetSharp.TwitterService(twitterSecret._OAuthConsumerKey, twitterSecret._OAuthConsumerSecret);

            service.AuthenticateWith(twitterSecret._OAuthAccessToken, twitterSecret._OAuthAccessTokenSecret);
            var TwitterStatus = service.Retweet(new RetweetOptions {
                Id = id
            });

            return("Retweeted successfully");
        }
Пример #39
0
        public JsonResult GetHomeTweetsSince(string userName, string Nick, long id)
        {
            var twitterSecret = new Social_media_access.Models.TwitterSecretData(userName, Nick);
            var service       = new TweetSharp.TwitterService(twitterSecret._OAuthConsumerKey, twitterSecret._OAuthConsumerSecret);

            service.AuthenticateWith(twitterSecret._OAuthAccessToken, twitterSecret._OAuthAccessTokenSecret);
            var _ListTweetsOnHomeTimelineOptions = new TweetSharp.ListTweetsOnHomeTimelineOptions();

            _ListTweetsOnHomeTimelineOptions.Count   = 11;
            _ListTweetsOnHomeTimelineOptions.SinceId = id;
            var tweets = service.ListTweetsOnHomeTimeline(_ListTweetsOnHomeTimelineOptions);

            return(Json(tweets, JsonRequestBehavior.AllowGet));
        }
Пример #40
0
        /// <summary>
        /// Authenticates credentials
        /// </summary>
        protected async Task AuthenticateAsync()
        {
            TweetSharp.TwitterService service = new TweetSharp.TwitterService(
                ConfigurationManager.AppSettings["TwitterConsumerKey"],
                ConfigurationManager.AppSettings["TwitterConsumerSecret"],
                ConfigurationManager.AppSettings["TwitterAccessToken"],
                ConfigurationManager.AppSettings["TwitterAccessTokenSecret"]
                );

            await Task.Run(() =>
            {
                service.AuthenticateWith(ConfigurationManager.AppSettings["TwitterAccessToken"],
                                         ConfigurationManager.AppSettings["TwitterAccessTokenSecret"]);
            }
                           );
        }
Пример #41
0
        public async Task <IActionResult> Create([Bind("MeetID,TrainingTypeID,TrainerID,MeetDate,Price")] Meeting meeting, string oauth_token, string oauth_verifier)
        {
            if (ModelState.IsValid)
            {
                var trainer = await _context.AspNetUsers.FindAsync(meeting.TrainerID);

                if (trainer == null)
                {
                    ViewData["NotFound"] = "The requested trainer is no longer available";
                    return(View("~/Views/Home/Index.cshtml"));
                }
                var trainingType = await _context.TrainingTypes.FindAsync(meeting.TrainingTypeID);

                if (trainingType == null)
                {
                    ViewData["NotFound"] = "The requested trainning method is no longer available";
                    return(View("~/Views/Home/Index.cshtml"));
                }

                _context.Add(meeting);
                await _context.SaveChangesAsync();

                string key         = "r6tXd2oaTFEqADpqI7GwsiR5o";
                string secret      = "6vqMDzhw0KmSiHXa7VXGARMc8FyEBIxK6EK52XyA6EopEIos4H";
                string token       = "1288845984898994179-vGxfZsfSKO2RpkQpdD3KcCTzoze9C1";
                string tokenSecret = "9xRofqqaVXfTaF8lChqBFlWbHwnnsdy9wN3xCPyr7BPRQ";
                var    service     = new TweetSharp.TwitterService(key, secret);
                service.AuthenticateWith(token, tokenSecret);
                TwitterUser user      = service.VerifyCredentials(new VerifyCredentialsOptions());
                var         traintype = await _context.TrainingTypes
                                        .FirstOrDefaultAsync(m => m.TrainingTypeId == meeting.TrainingTypeID);

                string message = string.Format("New {0} meeting is available at {1} {2}", traintype.Name, meeting.MeetDate.ToShortDateString(), meeting.MeetDate.ToShortTimeString());
                var    result  = service.SendTweet(new SendTweetOptions
                {
                    Status = message
                });


                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TrainingTypeID"] = new SelectList(_context.TrainingTypes, "TrainingTypeId", "Name");
            ViewData["TrainerID"]      = this.GetRelevantTrainersToSelect();
            return(View(meeting));
        }
Пример #42
0
        private void perfchart_fill1(data accelReport, string queue)
        {
            double resultx;
            double resulty;
            double resultz;
            string key         = "agOz9gCZATM58FI3ubCubyuot";
            string secret      = "57m1Xh5SGyuogn4zttjFpz6SHwRYBA9mpJdPNJHbXPoisf9KGn";
            string token       = "860367448268087296-yahVsCIdXOyDQzs7R9to8ITUurBaHHA";
            string tokenSecret = " wrGpbaIF98cGPXYuXZxMm0BYDLoyb7w4hq3GA2q5JzGhT";
            var    service     = new TweetSharp.TwitterService(key, secret);

            service.AuthenticateWith(token, tokenSecret);
            string message = "Peringatan telah terjadi gempa susulan dengan skala 6,3 dengan pusat gempa di lokasi Bandung";

            for (int i = 0; i < 40; i++)
            {
                resultx = ((double.Parse(accelReport.accelerations[i].x)));
                resulty = ((double.Parse(accelReport.accelerations[i].y)));
                resultz = ((double.Parse(accelReport.accelerations[i].z)));

                perfChart.AddValue((decimal)resultx);
                perfChart1.AddValue((decimal)resulty);
                perfChart2.AddValue((decimal)resultz);
                if (resultx > 9 || resulty > 9 || resultz > 9)
                {
                    //MessageBox.Show("TERJADI GEMPA");

                    textBox4.BeginInvoke(new Action(() => { textBox4.Text = "GEMPA"; }));
                    var result = service.SendTweet(new SendTweetOptions
                    {
                        Status = message
                    }
                                                   );
                    //lblResult.Text = result.Text.ToString();
                }
                Thread.Sleep(25);



                //defx = double.Parse(accelReport.accelerations[i].x);
                //defy = double.Parse(accelReport.accelerations[i].y);
                //defz = double.Parse(accelReport.accelerations[i].z);
            }
        }
Пример #43
0
        public static List <User> fetchTwitterDetails(string myHashTag)
        {
            txtHashTag = myHashTag;

            //List<IList<Object>> twitterResult = new List<IList<object>>();
            //List<Object> twitterObject = new List<object>();
            var userResult = new List <User>();

            TweetSharp.TwitterService twService = new TweetSharp.TwitterService(_ConsumerKey, _ConsumerSecret);
            twService.AuthenticateWith(_AccessToken, _AccessTokenSecret);

            var twSearch = twService.Search(new TweetSharp.SearchOptions
            {
                Q          = txtHashTag.Trim(),
                Resulttype = TweetSharp.TwitterSearchResultType.Recent,
                Count      = 1
            });

            if (twSearch == null)
            {
                Console.WriteLine("Something is wrong...could not fetch details!");
            }

            else
            {
                List <TwitterStatus> tweetList = new List <TwitterStatus>(twSearch.Statuses);
                var user = new User();

                //twitterStats = new TwitterStatus();
                //var list = twSearch.Statuses.ToList();

                foreach (TwitterStatus t in tweetList)
                {
                    Console.WriteLine("Profile name: " + t.Author.ScreenName + ", Number of followers: " + t.User.FollowersCount);
                    //add details to object

                    user.screenName     = t.Author.ScreenName;
                    user.followersCount = t.User.FollowersCount;
                }

                userResult.Add(user);
            }
            return(userResult);
        }
Пример #44
0
        public Application.Models.TwitterUser GetUserInfo(TwitterLoginDto twitterLogin)
        {
            TweetSharp.TwitterService service = new TweetSharp.TwitterService(_twitterSettings.AppId, _twitterSettings.AppSecret);

            // this is only temporary for testing purposes
            service.AuthenticateWith(_twitterSettings.AccessToken, _twitterSettings.AccessTokenSecret);

            // TODO: when we go in to production
            //var requestToken = new OAuthRequestToken
            //{
            //    Token = twitterLogin.OAuthToken
            //};
            //OAuthAccessToken accessToken = service.GetAccessToken(requestToken, twitterLogin.OAuthVerifier);
            //service.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);

            var user = service.VerifyCredentials(new VerifyCredentialsOptions());

            return(new Application.Models.TwitterUser
            {
                Name = user.Name,
                ScreenName = user.ScreenName
            });
        }
Пример #45
0
        private void btnClear_Click(object sender, EventArgs e)
        {
            perfChart.Clear();
            perfChart1.Clear();
            perfChart2.Clear();
            string a;

            string key         = "agOz9gCZATM58FI3ubCubyuot";
            string secret      = "57m1Xh5SGyuogn4zttjFpz6SHwRYBA9mpJdPNJHbXPoisf9KGn";
            string token       = "860367448268087296-yahVsCIdXOyDQzs7R9to8ITUurBaHHA";
            string tokenSecret = "wrGpbaIF98cGPXYuXZxMm0BYDLoyb7w4hq3GA2q5JzGhT";
            var    service     = new TweetSharp.TwitterService(key, secret);

            service.AuthenticateWith(token, tokenSecret);
            Console.WriteLine("Tweet Sent");
            string message = "Peringatan telah terjadi gempa susulan dengan skala 6,3 dengan pusat gempa di lokasi Bandung";

            {
                var result = service.SendTweet(new SendTweetOptions
                {
                    Status = message
                }

                                               );

                try
                {
                    a = result.Text.ToString();
                    Console.WriteLine(a);
                }
                catch (System.NullReferenceException z)
                {
                    Console.WriteLine("Tweet Failed");
                }
            }
        }
Пример #46
0
        public TweetsModel GetTweets(int numberOfResults, bool adminOverview)
        {
            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            var tweetsModel   = new TweetsModel {
                ShowAdminOverView = adminOverview
            };
            var member = umbracoHelper.MembershipHelper.GetCurrentMember();

            if (member == null || member.IsHq() == false)
            {
                tweetsModel.ShowAdminOverView = false;
            }

            List <TwitterStatus> filteredTweets = new List <TwitterStatus>();

            try
            {
                var tweets =
                    UmbracoContext.Current.Application.ApplicationCache.RuntimeCache.GetCacheItem <IEnumerable <TwitterStatus> >("UmbracoSearchedTweets",
                                                                                                                                 () =>
                {
                    var service = new TweetSharp.TwitterService(
                        ConfigurationManager.AppSettings["twitterConsumerKey"],
                        ConfigurationManager.AppSettings["twitterConsumerSecret"]);
                    service.AuthenticateWith(
                        ConfigurationManager.AppSettings["twitterUserAccessToken"],
                        ConfigurationManager.AppSettings["twitterUserAccessSecret"]);

                    var options = new SearchOptions
                    {
                        Count      = 100,
                        Resulttype = TwitterSearchResultType.Recent,
                        Q          = "umbraco"
                    };

                    var results = service.Search(options);
                    return(results.Statuses);
                }, TimeSpan.FromMinutes(2));

                var settingsNode = umbracoHelper.TypedContentAtRoot().FirstOrDefault();
                if (settingsNode != null)
                {
                    var usernameFilter = settingsNode.GetPropertyValue <string>("twitterFilterAccounts")
                                         .ToLowerInvariant().Split(',').Where(x => x != string.Empty).ToArray();
                    var wordFilter = settingsNode.GetPropertyValue <string>("twitterFilterWords")
                                     .ToLowerInvariant().Split(',').Where(x => x != string.Empty);

                    filteredTweets = tweets.Where(x =>
                                                  x.Author.ScreenName.ToLowerInvariant().ContainsAny(usernameFilter) == false &&
                                                  x.Text.ToLowerInvariant().ContainsAny(wordFilter) == false &&
                                                  x.Text.StartsWith("RT ") == false)
                                     .Take(numberOfResults)
                                     .ToList();
                }

                tweetsModel.Tweets = filteredTweets;
            }
            catch (Exception ex)
            {
                LogHelper.Error <TwitterService>("Could not get tweets", ex);
            }

            return(tweetsModel);
        }
 public dskfj3k4adsfDF23cnv34fOAdmin2mcbue767bnmn326568Controller(IDataSource data)
 {
     service = new TweetSharp.TwitterService(key, secret);
     service.AuthenticateWith(token, tokenSecret);
     db = data;
 }