Exemple #1
0
        // GET api/tweetapplications
        public Statuses GetTweetsWithHashTag(TwitterAuthTokenModel tokenModel, string hashTag, string sinceId = "0")
        {
            var timelineFormat = string.Format("https://api.twitter.com/1.1/search/tweets.json?f=realtime&q={0}&since_id={1}", hashTag, sinceId);
            var timelineUrl    = timelineFormat;

            Debug.Print(timelineUrl);
            var timeLineRequest      = (HttpWebRequest)WebRequest.Create(timelineUrl);
            var timelineHeaderFormat = "{0} {1}";

            timeLineRequest.Headers.Add("Authorization", string.Format(timelineHeaderFormat, tokenModel.token_type, tokenModel.access_token));
            timeLineRequest.Method = "Get";

            WebResponse timeLineResponse = timeLineRequest.GetResponse();
            var         timeLineJson     = string.Empty;

            Statuses hackApplyResponse = null;

            using (timeLineResponse)
            {
                using (var reader = new StreamReader(timeLineResponse.GetResponseStream()))
                {
                    timeLineJson      = reader.ReadToEnd();
                    hackApplyResponse = JsonConvert.DeserializeObject <Statuses>(timeLineJson);
                }
            }

            return(hackApplyResponse);
        }
Exemple #2
0
        public TweetModel GetTweet(TwitterAuthTokenModel tokenModel, string id)
        {
            var timelineFormat = string.Format("https://api.twitter.com/1.1/statuses/show.json?id={0}", id);

            var            timelineUrl          = string.Format(timelineFormat);
            HttpWebRequest timeLineRequest      = (HttpWebRequest)WebRequest.Create(timelineUrl);
            var            timelineHeaderFormat = "{0} {1}";

            timeLineRequest.Headers.Add("Authorization", string.Format(timelineHeaderFormat, tokenModel.token_type, tokenModel.access_token));
            timeLineRequest.Method = "Get";


            WebResponse timeLineResponse = timeLineRequest.GetResponse();

            var timeLineJson = string.Empty;

            TweetModel hackApplyResponse = null;

            using (timeLineResponse)
            {
                using (var reader = new StreamReader(timeLineResponse.GetResponseStream()))
                {
                    timeLineJson      = reader.ReadToEnd();
                    hackApplyResponse = JsonConvert.DeserializeObject <TweetModel>(timeLineJson);
                }
            }

            return(hackApplyResponse);
        }
Exemple #3
0
        public IEnumerable <TweetModel> GetApplicationTweets(TwitterAuthTokenModel tokenModel, string hashTag, string sinceId = "0")
        {
            var toReturn = new List <TweetModel>();

            //match any text with /Job/1234455 assumming this is a seek job id
            //Todo: decode tiny url and check if valid seek job
            string strRegex = @"/Job/\d+";
            var    regex    = new Regex(strRegex, RegexOptions.None);

            var statuses = GetTweetsWithHashTag(tokenModel, hashTag, sinceId);

            foreach (var status in statuses.statuses)
            {
                if (!status.in_reply_to_status_id_str.IsNullOrWhiteSpace())
                {
                    try
                    {
                        var repliedToTweet = GetTweet(tokenModel, status.in_reply_to_status_id_str);

                        if (regex.Matches(repliedToTweet.text).Cast <Match>().Any(myMatch => myMatch.Success))
                        {
                            status.jobUrl = repliedToTweet.text;
                            toReturn.Add(status);
                            status.DebugPrint();
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.Print(e.Message);
                    }
                }
            }

            return(toReturn);
        }
Exemple #4
0
        // POST api/tweet
        public TwitterStatus PostTweet(TwitterAuthTokenModel tokenModel, SendTweetOptions tweet)
        {
            TwitterService service = new TwitterService(OAuthConsumerKey, OAuthConsumerSecret);

            service.AuthenticateWith("2547463968-WK7dpHLhbwSkFn5ahxweGreCdqFQ4Yw9fnMDWQ7", "SriZkL4wipjDr74DsmjBbg6OSFSxNicm9z0sPpu9UbJd3");

            var ret = service.SendTweet(tweet);

            return(ret);
        }