Exemplo n.º 1
0
        public bool AcquireAccessToken(string oauthVerifier)
        {
            try {
                var wc = new WebClient();

                var url = new Uri(config.AccessTokenUrl);

                OAuthAuthorizer.AuthorizeRequest(TwitterAccount.OAuthConfig,
                                                 wc,
                                                 RequestToken,
                                                 RequestTokenSecret,
                                                 "POST",
                                                 url,
                                                 "oauth_verifier=" + Uri.EscapeDataString(oauthVerifier));

                var res = wc.UploadString(url, "");

                var tokens = Http.ParseQueryString(res);

                ScreenName        = tokens["screen_name"];
                UserId            = tokens["user_id"];
                AccessToken       = tokens["oauth_token"];
                AccessTokenSecret = tokens["oauth_token_secret"];

                return(true);
            }
            catch (Exception e) {
                Log.Error(e);
                return(false);
            }
        }
Exemplo n.º 2
0
        XDocument Api(string method, Uri uri)
        {
            if (_tokens == null)
            {
                using (var repo = new Repo()) {
                    _tokens = repo.Table <TwitterOAuthTokens>().Where(t => t.Account == Account).FirstOrDefault();
                }
            }

            if (_tokens == null)
            {
                throw new InvalidOperationException("Cannot access Twitter APIs without tokens");
            }

            var wc = new WebClient();

            OAuthAuthorizer.AuthorizeRequest(OAuthConfig, wc, _tokens.Token, _tokens.TokenSecret, method, uri, "");

            var res = "";

            if (method == "GET")
            {
                res = wc.DownloadString(uri);
            }
            else
            {
                res = wc.UploadString(uri, "");
            }

            return(XDocument.Parse(res));
        }
Exemplo n.º 3
0
        void Start()
        {
            _auth = new OAuthAuthorizer(TwitterAccount.OAuthConfig);

            if (_auth.AcquireRequestToken())
            {
                var authUrl = TwitterAccount.OAuthConfig.AuthorizeUrl + "?oauth_token=" + _auth.RequestToken;

                _web.LoadRequest(new NSUrlRequest(new NSUrl(authUrl)));
            }
            else
            {
                // F*****G TWITTER
                _scanner.StopScanning();
            }
        }
Exemplo n.º 4
0
        void Start()
        {
            _auth = new OAuthAuthorizer(TwitterAccount.OAuthConfig);

            if (_auth.AcquireRequestToken()) {

                var authUrl = TwitterAccount.OAuthConfig.AuthorizeUrl + "?oauth_token=" + _auth.RequestToken;

                _web.LoadRequest (new NSUrlRequest (new NSUrl (authUrl)));
            }
            else {
                // F*****G TWITTER
                _scanner.StopScanning();
            }
        }