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); }
static public void GetMoreTwitts(string tag, IRecepient recepient, List <Twitt> twittList) { _status = eStatus.GetMoreTwitts; if (IsAuthorized) { communicator.GetTwittsByTag(tag, recepient, twittList.LastOrDefault()); } else { //error } }
static public void GetTwitts(string tag, IRecepient recepient) { _status = eStatus.GetTwitts; tag = tag; if (IsAuthorized) { communicator.GetTwittsByTag(tag, recepient); } else { //error } }
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); }
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); } }
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; } }
public ShyBotRestRequest(string resource, Method method, IRecepient recepient) : base(resource, method) { Recepient = recepient; }
static public void Authorize(string query, IRecepient recepient) { _status = eStatus.Authorization; communicator.Authorize(query, recepient); }
static public void Authontificate(IRecepient recepient) { _status = eStatus.Authontification; communicator.Authenticate(recepient); //msg }