Exemplo n.º 1
0
        public void Authenticate(IRecepient recepient)
        {
            //get request_token

            _client.Authenticator = RestSharp.Authenticators.OAuth1Authenticator.ForRequestToken(_authInfo.ConsumerKey, _authInfo.ConsumerSecret, _authInfo.CallbackUrl);
            var request = new ShyBotRestRequest(_authInfo.AuthRequestTokenUrl, Method.POST, recepient);

            _client.ExecuteAsync(request, Authenticate_CallBack);
        }
Exemplo n.º 2
0
 static public void GetMoreTwitts(string tag, IRecepient recepient, List <Twitt> twittList)
 {
     _status = eStatus.GetMoreTwitts;
     if (IsAuthorized)
     {
         communicator.GetTwittsByTag(tag, recepient, twittList.LastOrDefault());
     }
     else
     {
         //error
     }
 }
Exemplo n.º 3
0
 static public void GetTwitts(string tag, IRecepient recepient)
 {
     _status = eStatus.GetTwitts;
     tag     = tag;
     if (IsAuthorized)
     {
         communicator.GetTwittsByTag(tag, recepient);
     }
     else
     {
         //error
     }
 }
Exemplo n.º 4
0
        public void GetTwittsByTag(string tag, IRecepient recepient, Twitt lastTwitt = null)
        {
            //get data

            _client.Authenticator = RestSharp.Authenticators.OAuth1Authenticator.ForProtectedResource(_authInfo.ConsumerKey, _authInfo.ConsumerSecret, _authInfo.OauthToken, _authInfo.OauthTokenSecret);
            var request = new ShyBotRestRequest("1.1/search/tweets.json", Method.GET, recepient);

            request.AddParameter("q", tag);
            if (lastTwitt != null)
            {
                request.AddParameter("max_id", lastTwitt.id_str);
            }

            _client.ExecuteAsync(request, GetTwittsByTag_CallBack);
        }
Exemplo n.º 5
0
        public void Authorize(string query, IRecepient recepient)
        {
            //authorize user
            if (query.Contains("oauth_verifier"))
            {
                _authParser.ParseResponse(query);


                _client.Authenticator = RestSharp.Authenticators.OAuth1Authenticator.ForAccessToken(_authInfo.ConsumerKey, _authInfo.ConsumerSecret, _authInfo.OauthToken,
                                                                                                    _authInfo.OauthTokenSecret, _authInfo.OauthVerifier);
                var request = new ShyBotRestRequest(_authInfo.AuthAccessTokenUrl, Method.POST, recepient);

                _client.ExecuteAsync(request, Authorize_CallBack);
            }
        }
Exemplo n.º 6
0
        static public void TryAgain(IRecepient recepient, string tag, List <Twitt> twittList)
        {
            switch (_status)
            {
            case (eStatus.Authontification):
            case (eStatus.Authorization):
                Authontificate(recepient);
                break;

            case (eStatus.GetTwitts):
                GetTwitts(tag, recepient);
                break;

            case (eStatus.GetMoreTwitts):
                GetMoreTwitts(tag, recepient, twittList);
                break;
            }
        }
Exemplo n.º 7
0
 public ShyBotRestRequest(string resource, Method method, IRecepient recepient) : base(resource, method)
 {
     Recepient = recepient;
 }
Exemplo n.º 8
0
 static public void Authorize(string query, IRecepient recepient)
 {
     _status = eStatus.Authorization;
     communicator.Authorize(query, recepient);
 }
Exemplo n.º 9
0
 static public void Authontificate(IRecepient recepient)
 {
     _status = eStatus.Authontification;
     communicator.Authenticate(recepient);
     //msg
 }