protected void FirstPos() { string url = ""; string xml = ""; oAuthTwitter oAuth = new oAuthTwitter(); oAuth.ConsumerKey = System.Configuration.ConfigurationManager.AppSettings["consumerkey"]; oAuth.ConsumerSecret = System.Configuration.ConfigurationManager.AppSettings["consumersecret"]; oAuth.CallBackUrl = SessionState.WebsiteURL + "twitter.aspx"; if (Request["oauth_token"] == null) { Response.Redirect(oAuth.AuthorizationLinkGet()); } else { //Get the access token and secret. oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]); verifier = Request["oauth_verifier"]; token = Request["oauth_token"]; if ((oAuth.TokenSecret.Length > 0)) { //We now have the credentials, so make a call to the Twitter API. url = "https://api.twitter.com/1.1/account/verify_credentials.json?test=test&include_entities=true&skip_status=true"; // url = "https://api.twitter.com/1.1/search/tweets.json"; xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, url, string.Empty); CheckAndRegister(xml); } } }
protected void imgTwitter_Click(object sender, ImageClickEventArgs e) { var oAuth = new oAuthTwitter(); if (Request["oauth_token"] == null) { //Redirect the user to Twitter for authorization. //Using oauth_callback for local testing. oAuth.CallBackUrl = "http://69.89.14.163:86/TwitterAuthentication.aspx"; Response.Redirect(oAuth.AuthorizationLinkGet()); } else { GetUserDetailsFromTwitter(); } }
//requestTokens protected void requestTokens() { //if token does not exist in filter, redirect and get token if (_twitterChecked) { if (_tokenFilter.twitterAuthToken == Constants.InvalidIdString || string.IsNullOrEmpty(_tokenFilter.twitterAuthToken) || _tokenFilter.twitterAuthToken == null) //if token does not exist in filter, redirect and get token { _twitterCacheKey = _twitterCacheKeyPrefix + "-" + _requestNonce + "-" + club.clubIdString; //creates random clubid cache key _twitterSecretKey = _twitterSecretKeyPrefix + "-" + _requestNonce + "-" + club.clubIdString; //uses same nonce in token cache key to create a token secret key oTwitter.CallBackUrl = "http://www.clubexpress.com/basic_modules/club_admin/website/auth_callback.aspx?type=twitter&state=" + _twitterCacheKey; _tokenFilter.twitterCacheKey = _twitterCacheKey; _tokenFilter.twitterSecretKey = _twitterSecretKey; _twitterString = oTwitter.AuthorizationLinkGet(); // Response.Write("<script>window.open('" + _twitterString + "', \"_blank\", \"toolbar=yes, scrollbars=yes, resizable=yes, width=580, height=400\");</script>"); _popupString = _twitterString; } } if (_linkedInChecked) { if (_tokenFilter.linkedinToken == Constants.InvalidIdString || string.IsNullOrEmpty(_tokenFilter.linkedinToken) || _tokenFilter.linkedinToken == null) { _linkedInCacheKey = _linkedInCacheKeyPrefix + "-" + _requestNonce + "-" + club.clubIdString; //creates random clubid cache key _tokenFilter.linkedInCacheKey = _linkedInCacheKey; _linkedInString = oLinkedIn.AuthorizationLinkGet(_linkedInCacheKey); // Response.Write("<script>window.open('" + _linkedInString + "', \"_blank\", \"toolbar=yes, scrollbars=yes, resizable=yes, width=580, height=400\");</script>"); _popupString = _linkedInString; } } if (_faceBookChecked) { if (_tokenFilter.facebookToken == Constants.InvalidIdString || string.IsNullOrEmpty(_tokenFilter.facebookToken) || _tokenFilter.facebookToken == null) //if token does not exist in filter, redirect and get token { _facebookCacheKey = _facebookCacheKeyPrefix + "-" + _requestNonce + "-" + club.clubIdString; //creates random clubid cache key _tokenFilter.facebookCacheKey = _facebookCacheKey; _facebookString = oFB.AuthorizationLinkGet(_facebookCacheKey); // Response.Write("<script>window.open('" + _facebookString + "', \"_blank\", \"toolbar=yes, scrollbars=yes, resizable=yes, width=580, height=450\");</script>"); _popupString = _facebookString; } } if (!string.IsNullOrEmpty(_popupString)) { Response.Write("<script>window.open('" + _popupString + "', \"_blank\", \"toolbar=yes, scrollbars=yes, resizable=yes, width=580, height=450\");</script>"); } sessionData.addDataItem("TokenFilter", _tokenFilter); }
protected void Page_Load(object sender, EventArgs e) { string url = ""; string xml = ""; oAuthTwitter oAuth = new oAuthTwitter(); result.Text = DateTime.UtcNow.ToString(); if (Request["oauth_token"] == null) { //Redirect the user to Twitter for authorization. //Using oauth_callback for local testing. oAuth.CallBackUrl = "http://spindate.comstar.co.il/twitter.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"; url = "https://api.twitter.com/1.1/account/verify_credentials.json"; string data = String.Empty; data = "include_entities=false&skip_status=true"; xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, url, data); //apiResponse.InnerHtml = Server.HtmlEncode(xml); string responseData = Server.HtmlEncode(xml); System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); //creating a JSON deserializer JSON. Rootobject myToken1 = serializer.Deserialize <Rootobject>(xml); apiResponse.InnerHtml = myToken1.name; //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); } } }
public static TwitterAuthInfo TwitterAuthGetPin() { // authorize ZScreen to twitter oAuthTwitter oAuth = new oAuthTwitter(Engine.TWITTER_CONSUMER_KEY, Engine.TWITTER_CONSUMER_SECRET); TwitterAuthInfo acc = TwitterGetActiveAcct(); string authLink = oAuth.AuthorizationLinkGet(); if (!string.IsNullOrEmpty(acc.AccountName)) { oAuth.AuthInfo.AccountName = acc.AccountName; } if (CheckTwitterAccounts()) { Engine.conf.TwitterAccountsList[Engine.conf.TwitterAcctSelected] = oAuth.AuthInfo; } if (!string.IsNullOrEmpty(authLink)) { System.Diagnostics.Process.Start(authLink); } return(oAuth.AuthInfo); }
public void TwitterRedirect(object sender, EventArgs e) { if (ddlGroup.SelectedItem.Text != "Select") { Session["UserAndGroupsForTwitter"] = "twitter"; oAuthTwitter OAuth = new oAuthTwitter(); if (Request["oauth_token"] == null) { OAuth.AccessToken = string.Empty; OAuth.AccessTokenSecret = string.Empty; OAuth.CallBackUrl = ConfigurationManager.AppSettings["callbackurl"].ToString(); Response.Redirect(OAuth.AuthorizationLinkGet()); } } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "test", "<script type=\"text/javascript\">alert(\"Select the group to add profiles\")</script>", false); } }
/// <summary> /// Post the flight to Twitter /// </summary> /// <param name="le">The logbook entry being posted</param> /// <returns>true for success</returns> public Boolean PostFlight(LogbookEntry le) { if (le == null) { throw new ArgumentNullException("le"); } Boolean fResult = false; oAuthTwitter oAuth = new oAuthTwitter(); GetUserTwitterToken(le.User, oAuth); if (oAuth.Token.Length == 0 && Request["oauth_token"] == null) { PendingFlightToPost = le; // hold on to this logbook entry for post-authorization... //Redirect the user to Twitter for authorization. oAuth.CallBackUrl = "~/member/PostFlight.aspx".ToAbsoluteURL(Request).ToString(); SocialNetworkAuthorization.PushRedirect(oAuth.AuthorizationLinkGet()); } else { if (oAuth.TokenSecret.Length == 0) { oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]); SetUserTwitterToken(Page.User.Identity.Name, oAuth); } if (new TwitterPoster().PostToSocialMedia(le, Page.User.Identity.Name, Request.Url.Host)) { FDefaultTwitterCheckboxState = true; fResult = true; } } return(fResult); }
AuthorizeIfRequested() { AssertValid(); switch (m_oTwitterAuthorizationControl.Status) { case TwitterAuthorizationStatus.HasTwitterAccountAuthorized: return(true); case TwitterAuthorizationStatus.HasTwitterAccountNotAuthorized: TwitterAccessToken.Delete(); // Continue below. break; default: Debug.Assert(false); break; } // Get a Twitter request token. oAuthTwitter oTwitterAuth = new oAuthTwitter( HttpNetworkAnalyzerBase.UserAgent, HttpNetworkAnalyzerBase.HttpWebRequestTimeoutMs); Uri oAuthorizationUri = new Uri(oTwitterAuth.AuthorizationLinkGet()); String sRequestToken = HttpUtility.ParseQueryString( oAuthorizationUri.Query)["oauth_token"]; Debug.Assert(!String.IsNullOrEmpty(sRequestToken)); // Open the Twitter authorization page. Process.Start(oAuthorizationUri.ToString()); // Tell the user that the Twitter authorization page has been opened in // a browser window, and get the PIN that Twitter provides after // authorization is complete. TwitterAuthorizingDialog oTwitterAuthorizingDialog = new TwitterAuthorizingDialog(); if (oTwitterAuthorizingDialog.ShowDialog( m_oTwitterAuthorizationControl.ParentForm) != DialogResult.OK) { return(false); } // Convert the request token to an access token. oTwitterAuth.Token = sRequestToken; oTwitterAuth.AccessTokenGet( sRequestToken, oTwitterAuthorizingDialog.Pin); Debug.Assert(!String.IsNullOrEmpty(oTwitterAuth.Token)); Debug.Assert(!String.IsNullOrEmpty(oTwitterAuth.TokenSecret)); // Save the access token. TwitterAccessToken oTwitterAccessToken = new TwitterAccessToken(); oTwitterAccessToken.Save(oTwitterAuth.Token, oTwitterAuth.TokenSecret); return(true); }