Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string url = "";
            string xml = "";
            oAuthTwitter oAuth = new oAuthTwitter();

            if (Request["oauth_token"] == null)
            {
                //Redirect the user to Twitter for authorization.
                //Using oauth_callback for local testing.
                oAuth.CallBackUrl = "http://localhost";
                Response.Redirect(oAuth.AuthorizationLinkGet());
            }
            else
            {
                //Get the access token and secret.
                oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]);
                if (oAuth.TokenSecret.Length > 0)
                {
                    //We now have the credentials, so make a call to the Twitter API.
                    url = "http://twitter.com/account/verify_credentials.xml";
                    xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, url, String.Empty);
                    apiResponse.InnerHtml = Server.HtmlEncode(xml);

                    //POST Test
                    //url = "http://twitter.com/statuses/update.xml";
                    //xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, url, "status=" + oAuth.UrlEncode("Hello @swhitley - Testing the .NET oAuth API"));
                    //apiResponse.InnerHtml = Server.HtmlEncode(xml);
                }
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string       url   = "";
            string       xml   = "";
            oAuthTwitter oAuth = new oAuthTwitter();

            if (Request["oauth_token"] == null)
            {
                //Redirect the user to Twitter for authorization.
                //Using oauth_callback for local testing.
                oAuth.CallBackUrl = "http://localhost";
                Response.Redirect(oAuth.AuthorizationLinkGet());
            }
            else
            {
                //Get the access token and secret.
                oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]);
                if (oAuth.TokenSecret.Length > 0)
                {
                    //We now have the credentials, so make a call to the Twitter API.
                    url = "http://twitter.com/account/verify_credentials.xml";
                    xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, url, String.Empty);
                    apiResponse.InnerHtml = Server.HtmlEncode(xml);

                    //POST Test
                    //url = "http://twitter.com/statuses/update.xml";
                    //xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, url, "status=" + oAuth.UrlEncode("Hello @swhitley - Testing the .NET oAuth API"));
                    //apiResponse.InnerHtml = Server.HtmlEncode(xml);
                }
            }
        }
Example #3
0
        //-------------------------------------------------------------------------
        // ポスト(xAuth版)
        //-------------------------------------------------------------------------
        public bool Post(string iMessage,string iTopic)
        {
            if (Properties.Settings.Default.tw_token.Length == 0 ||
                Properties.Settings.Default.tw_token_secret.Length == 0)
                return false;

            if (iTopic.Length > 0)
                iMessage += " " + iTopic;

            oAuthTwitter oAuth = new oAuthTwitter();
            oAuth.Token = Properties.Settings.Default.tw_token;
            oAuth.TokenSecret = Properties.Settings.Default.tw_token_secret;
            string url = "http://twitter.com/statuses/update.xml";
            string xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, url, "status=" + oAuth.UrlEncode(iMessage));
            oAuth = null;
            return true;
        }
Example #4
0
        //-------------------------------------------------------------------------
        // xAuth認証
        //-------------------------------------------------------------------------
        public bool xAuth( string iUserID, string iPasswd )
        {
            oAuthTwitter oAuth = new oAuthTwitter();
            oAuth.xAuthAccessTokenGet(iUserID, iPasswd);

            if (oAuth.TokenSecret.Length > 0)
            {
                // TokenとTokenSecretを待避
                Debug.WriteLine(oAuth.Token);
                Debug.WriteLine(oAuth.TokenSecret);

                Properties.Settings.Default.tw_passwd = "";
                Properties.Settings.Default.tw_user = "";

                Properties.Settings.Default.tw_token = oAuth.Token;
                Properties.Settings.Default.tw_token_secret = oAuth.TokenSecret;
                return true;
            }
            return false;
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string url = "";
            string xml = "";
            oAuthTwitter oAuth = new oAuthTwitter();

            if (Request["oauth_token"] == null)
            {
                //Redirect the user to Twitter for authorization.
                //Using oauth_callback for local testing.
                oAuth.CallBackUrl = Request.Url.AbsoluteUri;// "Default.aspx";
                Response.Redirect(oAuth.AuthorizationLinkGet());
            }
            else
            {
                //Get the access token and secret.
                oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]);
                if (oAuth.TokenSecret.Length > 0)
                {
                    //We now have the credentials, so make a call to the Twitter API.
                    url = "http://twitter.com/account/verify_credentials.xml";
                    xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, url, String.Empty);
                    apiResponse.InnerHtml = Server.HtmlEncode(xml);

                    //POST Test
                    //url = "http://twitter.com/statuses/update.xml";
                    //xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, url, "status=" + oAuth.UrlEncode("Hello @monirabuhilal - Testing the .NET oAuth API"));
                    //apiResponse.InnerHtml = Server.HtmlEncode(xml);
                }
            }
            //POST Test
            url = "http://twitter.com/statuses/update.xml";
            //"Hello @monirabuhilal - Testing the .NET oAuth API http://bit.ly/Vote4Jo"
            xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, url, "status=" + oAuth.UrlEncode(Request["t"]));
            //apiResponse.InnerHtml = Server.HtmlEncode(xml);
            apiResponse.InnerHtml = "<script type='text/javascript'>window.opener='x';window.close();</script>";
        }