/// <summary> /// Searches Twitter with the the specified query. /// </summary> /// <param name="query">The query.</param> /// <param name="tokens">The tokens. Leave null for unauthenticated request.</param> /// <param name="options">The options. Leave null for defaults.</param> /// <returns> /// A <see cref="TwitterSearchResultCollection"/> instance. /// </returns> public static async Task<TwitterResponse<TwitterSearchResultCollection>> SearchAsync(string query, OAuthTokens tokens = null, SearchOptions options = null) { if (options == null) options = new SearchOptions(); return await Core.CommandPerformer.PerformAction(new Twitterizer.Commands.SearchCommand(tokens, query, options)); }
public async Task<IEnumerable<TwitterSchema>> SearchAsync(string hashTag, OAuthTokens tokens) { try { var uri = new Uri(string.Format("https://api.twitter.com/1.1/search/tweets.json?q={0}", Uri.EscapeDataString(hashTag))); var rawResult = await _request.ExecuteAsync(uri, tokens); var result = JsonConvert.DeserializeObject<TwitterSearchResult>(rawResult); return result.statuses .Select(r => new TwitterSchema(r)) .ToList(); } catch (WebException wex) { HttpWebResponse response = wex.Response as HttpWebResponse; if (response != null) { if ((int)response.StatusCode == 429) { return GenerateErrorTweet("Too many requests. Please refresh in a few minutes."); } if (response.StatusCode == HttpStatusCode.Unauthorized) { return GenerateErrorTweet("The keys provided have been revoked or deleted."); } } throw; } }
public async Task<IEnumerable<TwitterSchema>> GetHomeTimeLineAsync(OAuthTokens tokens) { try { var uri = new Uri("https://api.twitter.com/1.1/statuses/home_timeline.json"); var rawResult = await _request.ExecuteAsync(uri, tokens); var result = JsonConvert.DeserializeObject<TwitterTimeLineItem[]>(rawResult); return result .Select(r => new TwitterSchema(r)) .ToList(); } catch (WebException wex) { HttpWebResponse response = wex.Response as HttpWebResponse; if (response != null) { if ((int)response.StatusCode == 429) { return GenerateErrorTweet("Too many requests. Please refresh in a few minutes."); } if (response.StatusCode == HttpStatusCode.Unauthorized) { return GenerateErrorTweet("The keys provided have been revoked or deleted."); } } throw; } }
/// <summary> /// Initializes a new instance of the <see cref="MentionsCommand"/> class. /// </summary> /// <param name="tokens">The request tokens.</param> /// <param name="options">The options.</param> public MentionsCommand(OAuthTokens tokens, TimelineOptions options) : base(HTTPVerb.GET, "statuses/mentions_timeline.json", tokens, options) { if (tokens == null) { throw new ArgumentNullException("tokens"); } }
/// <summary> /// Initializes a new instance of the <see cref="HomeTimelineCommand"/> class. /// </summary> /// <param name="tokens">The request tokens.</param> /// <param name="optionalProperties">The optional properties.</param> public HomeTimelineCommand(OAuthTokens tokens, TimelineOptions optionalProperties) : base(HTTPVerb.GET, "statuses/home_timeline.json", tokens, optionalProperties) { if (tokens == null) { throw new ArgumentNullException("tokens"); } }
public OAuthTokens authTwitter(string ConsumerKey, string ConsumerSecret, string AccessToken, string AccessTokenSecret) { OAuthTokens tokens = new OAuthTokens(); tokens.ConsumerKey = ConsumerKey; tokens.ConsumerSecret= ConsumerSecret; tokens.AccessToken = AccessToken; tokens.AccessTokenSecret=AccessTokenSecret; return tokens; }
public async Task<string> ExecuteAsync(Uri requestUri, OAuthTokens tokens) { var request = CreateRequest(requestUri, tokens); var response = await request.GetResponseAsync(); using (StreamReader sr = new StreamReader(response.GetResponseStream())) { return sr.ReadToEnd(); } }
public TwitterStreaming(OAuthTokens Tokens, string TwitterAccount, Decimal TwitterAccountID) { this.TwitterAccount = TwitterAccount; this.TwitterAccountID = TwitterAccountID; this.Stream = new Stream(Tokens, string.Format("MetroTwit/{0}", (object) ((object) System.Windows.Application.ResourceAssembly.GetName().Version).ToString()), (StreamOptions) new UserStreamOptions() { AllReplies = App.AppState.Accounts[this.TwitterAccountID].Settings.AllReplies }); this.Stopped = true; this.StartStream(); }
private static WebRequest CreateRequest(Uri requestUri, OAuthTokens tokens) { var requestBuilder = new OAuthRequestBuilder(requestUri, tokens); var request = (HttpWebRequest)WebRequest.Create(requestBuilder.EncodedRequestUri); request.UseDefaultCredentials = true; request.Method = OAuthRequestBuilder.Verb; request.Headers["Authorization"] = requestBuilder.AuthorizationHeader; return request; }
/// <summary> /// Searches Twitter with the the specified query. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="query">The query.</param> /// <param name="options">The options.</param> /// <returns> /// A <see cref="TwitterSearchResultCollection"/> instance. /// </returns> public static TwitterResponse<TwitterSearchResultCollection> Search(OAuthTokens tokens, string query, SearchOptions options) { if (options == null) options = new SearchOptions(); Commands.SearchCommand command = new Twitterizer.Commands.SearchCommand(tokens, query, options); TwitterResponse<TwitterSearchResultCollection> results = Core.CommandPerformer.PerformAction(command); return results; }
/// <summary> /// Initializes a new instance of the <see cref="UserTimelineCommand"/> class. /// </summary> /// <param name="tokens">The request tokens.</param> /// <param name="options">The options.</param> public UserTimelineCommand(OAuthTokens tokens, UserTimelineOptions options) : base(HTTPVerb.GET, "statuses/user_timeline.json", tokens, options) { if (tokens == null && options == null) { throw new ArgumentException("You must supply either OAuth tokens or identify a user in the TimelineOptions class."); } if (options != null && tokens == null && string.IsNullOrEmpty(options.ScreenName) && options.UserId <= 0) { throw new ArgumentException("You must specify a user's screen name or id for unauthorized requests."); } }
public string sendTweet(string tweet, OAuthTokens tokens) { StatusUpdateOptions options = new StatusUpdateOptions() { UseSSL = true, APIBaseAddress = "http://api.twitter.com/1.1/" }; TwitterResponse<TwitterStatus> response = TwitterStatus.Update(tokens, tweet, options); if (response.Result == RequestResult.Success) { return "bueno "; } else { return "malo "; } }
public OAuthRequestBuilder(Uri requestUri, OAuthTokens tokens) { RequestUriWithoutQuery = new Uri(requestUri.AbsoluteWithoutQuery()); QueryParams = requestUri.GetQueryParams() .Select(p => new OAuthParameter(p.Key, p.Value)) .ToList(); EncodedRequestUri = GetEncodedUri(requestUri, QueryParams); Version = new OAuthParameter("oauth_version", "1.0"); Nonce = new OAuthParameter("oauth_nonce", GenerateNonce()); Timestamp = new OAuthParameter("oauth_timestamp", GenerateTimeStamp()); SignatureMethod = new OAuthParameter("oauth_signature_method", "HMAC-SHA1"); ConsumerKey = new OAuthParameter("oauth_consumer_key", tokens["ConsumerKey"]); ConsumerSecret = new OAuthParameter("oauth_consumer_secret", tokens["ConsumerSecret"]); Token = new OAuthParameter("oauth_token", tokens["AccessToken"]); TokenSecret = new OAuthParameter("oauth_token_secret", tokens["AccessTokenSecret"]); }
/// <summary> /// Enables device notifications for updates from the specified user. Returns the specified user when successful. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="userId">The user id.</param> /// <returns></returns> public static TwitterResponse<TwitterUser> Follow(OAuthTokens tokens, decimal userId) { return Follow(tokens, userId, null); }
/// <summary> /// Enables device notifications for updates from the specified user. Returns the specified user when successful. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="screenName">The user's screen name.</param> /// <returns></returns> public static TwitterResponse<TwitterUser> Follow(OAuthTokens tokens, string screenName) { return Follow(tokens, screenName, null); }
/// <summary> /// Initializes a new instance of the <see cref="IncomingFriendshipsCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> public IncomingFriendshipsCommand(OAuthTokens tokens, IncomingFriendshipsOptions options) : base(HTTPVerb.GET, "friendships/incoming.json", tokens, options) { this.DeserializationHandler = TwitterCursorPagedIdCollection.DeserializeWrapper; }
/// <summary> /// Returns a collection of IDs for every protected user for whom the authenticating user has a pending follow request. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> /// <returns></returns> public static async Task<TwitterResponse<TwitterCursorPagedIdCollection>> OutgoingRequestsAsync(OAuthTokens tokens, OutgoingFriendshipsOptions options = null) { return await Core.CommandPerformer.PerformAction(new Commands.OutgoingFriendshipsCommand(tokens, options)); }
/// <summary> /// Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> /// <returns></returns> public static async Task<TwitterResponse<TwitterUserCollection>> LookupAsync(OAuthTokens tokens, LookupUsersOptions options) { return await Core.CommandPerformer.PerformAction(new Commands.LookupUsersCommand(tokens, options)); }
public async Task <IEnumerable <TwitterSchema> > GetUserTimeLineAsync(string screenName, OAuthTokens tokens) { try { var uri = new Uri(string.Format("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name={0}", screenName)); var rawResult = await _request.ExecuteAsync(uri, tokens); var result = JsonConvert.DeserializeObject <TwitterTimeLineItem[]>(rawResult); return(result .Select(r => new TwitterSchema(r)) .ToList()); } catch (WebException wex) { HttpWebResponse response = wex.Response as HttpWebResponse; if (response != null) { if (response.StatusCode == HttpStatusCode.NotFound) { return(GenerateErrorTweet(string.Format("User '{0}' not found", screenName))); } if ((int)response.StatusCode == 429) { return(GenerateErrorTweet("Too many requests. Please refresh in a few minutes.")); } if (response.StatusCode == HttpStatusCode.Unauthorized) { return(GenerateErrorTweet("The keys provided have been revoked or deleted.")); } } throw; } }
}//end of InitializePagingVars() protected void Page_PreRender(object sender, EventArgs e) { try { //code will load and initialize the JavaScript SDK with all standard options if (!Page.ClientScript.IsClientScriptBlockRegistered("facebook_api")) Page.ClientScript.RegisterClientScriptInclude("facebook_api", String.Format("http://connect.facebook.net/{0}/all.js", "en_US")); if (!Page.ClientScript.IsStartupScriptRegistered("facebook_api_init")) Page.ClientScript.RegisterStartupScript(typeof(string), "facebook_api_init", String.Format("FB.init({{appId: '{0}', status: true, cookie: true, xfbml: true, oauth: true }});", "574005609290762"), true); if (!Page.ClientScript.IsStartupScriptRegistered("facebook_login")) { string facebookLogin = String.Format("function fblogin() {{ FB.login(function(response) {{ if (response.authResponse) {{ {0} }} else {{ {1} }}}}, {{ scope: '{2}' }});}}", this.Page.ClientScript.GetPostBackEventReference(this.Page, "FacebookLogin", false), this.Page.ClientScript.GetPostBackEventReference(this.Page, "FacebookLogout", false), "publish_stream,email"); Page.ClientScript.RegisterStartupScript(typeof(string), "facebook_login", facebookLogin, true); }//end of if if (!Page.ClientScript.IsStartupScriptRegistered("facebook_logout")) { string facebookLogout = String.Format("function fblogout() {{ FB.logout(function(response) {{ {0} }}); }}", this.Page.ClientScript.GetPostBackEventReference(this.Page, "FacebookLogout", false)); Page.ClientScript.RegisterStartupScript(typeof(string), "facebook_logout", facebookLogout, true); }//end of if FacebookApp facebookApp = new FacebookApp();//holds an object of the FB //checks if the user is connected to the session if (facebookApp.Session != null && facebookApp.AccessToken != null) { var facebookUser = facebookApp.Api("me") as JsonObject;//holds the object of the user //checks if the the user has submited a condolence if(panCondoloncesThankYou.Visible == false) //displays the Condolace section panLeaveCondolence.Style.Add("display", "block"); else //closes the Leave Condolence section panLeaveCondolence.Style.Add("display", "none"); //removes the socail and user text boxes as the user is now already sign in //and turns on the label of the user and displays the logout button panCondolenceSocialOption.Visible = false; panConEnterNameEmail.Visible = false; panConNameEmail.Visible = true; panLogOutFB.Visible = true; //checks if there is a user name if (facebookUser.ContainsKey("username") && facebookUser["username"] != null) lblConnectedUser.Text = facebookUser["username"].ToString(); //checks if there is a name from FB if (facebookUser.ContainsKey("name") && facebookUser["name"] != null) //displays the name from FB lblConnectedName.Text = facebookUser["name"].ToString(); //checks if there is a email from FB if (facebookUser.ContainsKey("email") && facebookUser["email"] != null) //displays the email from FB lblConnectedEmail.Text = facebookUser["email"].ToString(); //sets the which social network the user is usiing hfObituaryCondolenceSocialNetwork.Value = "1"; }//end of if else { //adds the Social Options and allow the user to enter their own email //and removes the FB Logout and email panCondolenceSocialOption.Visible = true; panConEnterNameEmail.Visible = true; panConNameEmail.Visible = false; panLogOutFB.Visible = false; //resets all of the social fields lblConnectedUser.Text = ""; lblConnectedName.Text = ""; lblConnectedEmail.Text = ""; hfObituaryCondolenceSocialNetwork.Value = "0"; }//end of else //checks if the user is logged into twitter if (Request["oauth_token"] != null) { Session["TwitterRequestToken"] = Request["oauth_token"].ToString(); Session["TwitterPin"] = Request["oauth_verifier"].ToString(); var tokens = OAuthUtility.GetAccessToken( ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], Session["TwitterRequestToken"].ToString(), Session["TwitterPin"].ToString()); OAuthTokens oatAccess = new OAuthTokens() { AccessToken = tokens.Token, AccessTokenSecret = tokens.TokenSecret, ConsumerKey = ConfigurationManager.AppSettings["consumerKey"], ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"] }; TwitterResponse<TwitterUser> twitterResponse = TwitterAccount.VerifyCredentials(oatAccess);//holds the response that has come from twitter with if this is a good token if (twitterResponse.Result == RequestResult.Success) { //We now have the credentials, so make a call to the Twitter API. HtmlMeta hmTwitter = new HtmlMeta();//holds the meta takes that will go into the header HtmlHead head = (HtmlHead)Page.Header;//holds the reference of the Header //removes the socail and user text boxes as the user is now already sign in //and turns on the label of the user panCondolenceSocialOption.Visible = false; panConEnterNameEmail.Visible = false; panConNameEmail.Visible = true; //sets the which social network the user is usiing hfObituaryCondolenceSocialNetwork.Value = "2"; //sets the username and actully name lblConnectedUser.Text = twitterResponse.ResponseObject.ScreenName; lblConnectedName.Text = twitterResponse.ResponseObject.Name; //define an HTML meta twitter:creator in the header hmTwitter.Name = "twitter:creator"; hmTwitter.Content = lblConnectedUser.Text; hmTwitter.Controls.Add(hmTwitter); //because twitter does not allow access to the email address this should not be display panConnectedEmail.Visible = false; }//end of if }//end of if DataTable dtObituaryDetails = null; if (panSidebarLinks.Visible) dtObituaryDetails = DAL.getRow("", "WHERE = '" + General.ObituaryStatus.Published.ToString() + "' AND = " + hfObituaryID.Value);//holds the Obituary details else dtObituaryDetails = DAL.getRow("", "WHERE = " + hfObituaryID.Value);//holds the Obituary details //checks if there is any details for this obituary if (dtObituaryDetails != null && dtObituaryDetails.Rows.Count > 0) { int intIndexServiceID = 0;//holds the unquie id of the row string strLastFHID = "";//holds what is the last FHID string strShareDescription = "";//holds the description that will share to the world DataTable dtImage = DAL.getRow("","Where = " + hfObituaryID.Value + " Order by ");//holds the Images for this Obituary DataTable dtObitService = DAL.getRow("", "WHERE = " + hfObituaryID.Value + " Order by , , ");//gets all services for this obituary DataTable dtObitFlowers = DAL.getRow("", "WHERE = " + hfObituaryID.Value + " AND = 1 Order by , ");//holds the Flower Recipient DataTable dtObitCards = DAL.queryDbTable("SELECT , , + ' ' + FROM WHERE = " + hfObituaryID.Value + " AND = 1"); //checks if there is any images to display if(dtImage.Rows.Count > 0) //sets an iframe to display the image slider as the image slider uses a advance jquery //the DNN does not run litImageSlider.Text = "<iframe id='iframeImageSlider' src='/ImageSlider.aspx?=" + hfObituaryID.Value + "' scrolling='no'></iframe>"; //checks if this is PrePla or Memorial n if so then change the text for Leave Condolence if (dtObituaryDetails.Rows[0][""].ToString() == ((int)General.ObituaryType.PrePlan).ToString() || dtObituaryDetails.Rows[0][""].ToString() == ((int)General.ObituaryType.Memorial).ToString()) { hlLeaveCondolence.Text = "Leave a Condolence or Message"; lblNoOfCondolences.Text = " Condolences or Messages"; panLeaveCondolenceTitleLeft.CssClass += " divLeaveCondolenceMmemoralTitleLeft"; }//end of if //checks if this user is logged in and they have not logged into a soical network //get there there details instead of typing it in if(Session[""] != null && panConNameEmail.Visible == false) { DataTable dtUserDetails = DAL.getRow("", "WHERE = " + Session[""].ToString());//holds the this user detail that is logged in //sets the users name and email to tell the user that this is what is going to be displayed lblConnectedName.Text = dtUserDetails.Rows[0][""].ToString() + " " + dtUserDetails.Rows[0][""].ToString(); lblConnectedEmail.Text = dtUserDetails.Rows[0][""].ToString(); lblReminderEmail.Text = dtUserDetails.Rows[0][""].ToString(); //displays the user name and email to tell the user who the are login in as panConNameEmail.Visible = true; //lblReminderEmail.Visible = true; panConEnterNameEmail.Visible = false; panCondolenceSocialOption.Visible = false; }//end of if //sets the condolences, the number of them for this Obituary and paging BindDesignsPanel(); //sets the on Click for the link Leave Condolence to turn it off and on hlLeaveCondolence.Attributes.Add("onClick", "javascript:toggleLayer('" + panLeaveCondolence.ClientID + "', '', '');"); hlSectionCondolence.Attributes.Add("onClick", "javascript:toggleLayer('" + panLeaveCondolence.ClientID + "', '', '');" + panLeaveCondolence.ClientID + ".scrollIntoView(true);"); //sets the basis settings lblName.Text = dtObituaryDetails.Rows[0][""].ToString() + ", " + dtObituaryDetails.Rows[0][""].ToString() + " " + dtObituaryDetails.Rows[0][""].ToString(); lblPrintName.Text = dtObituaryDetails.Rows[0][""].ToString() + ", " + dtObituaryDetails.Rows[0][""].ToString() + " " + dtObituaryDetails.Rows[0][""].ToString(); //sets the sidebar name of the user lblShareForName.Text = dtObituaryDetails.Rows[0][""].ToString() + " " + dtObituaryDetails.Rows[0][""].ToString(); lblReminderForName.Text = dtObituaryDetails.Rows[0][""].ToString() + " " + dtObituaryDetails.Rows[0][""].ToString(); lblReminderForName2.Text = dtObituaryDetails.Rows[0][""].ToString() + " " + dtObituaryDetails.Rows[0][""].ToString(); //sets the title of the page Page.Title = "The Obituaries - Details for " + dtObituaryDetails.Rows[0][""].ToString() + " " + dtObituaryDetails.Rows[0][""].ToString(); //sets the flower FH sidebar panFlowersFH.Visible = Convert.ToBoolean(dtObituaryDetails.Rows[0][""].ToString()); //checks if there is a FHID if (Convert.ToInt32(dtObituaryDetails.Rows[0][""].ToString()) > 0) { //sets the FHID for this flower request hlFlowerFH.NavigateUrl += dtObituaryDetails.Rows[0][""].ToString() + "&oid=" + hfObituaryID.Value; chkFuneralHome.Text = " All announcements from <strong>" + DAL.queryDbScalar("SELECT FROM WHERE = '" + dtObituaryDetails.Rows[0][""].ToString() + "'") + "</strong>"; }//end of if else //removes the Flowers FH is there is no FHID to use panFlowersFH.Visible = chkFuneralHome.Visible = false; //sets the Anotehr Address URL for flowers and cards hlSendCardsAnotherAddress.NavigateUrl = "/Obituaries/sympathycards.aspx?ObituariesID=" + hfObituaryID.Value; hlSendFlowersAnotherAddress.NavigateUrl = "/Obituaries/flower.aspx?person=2&FHPID=0&oid=" + hfObituaryID.Value; //checks if there is any flowsers if(dtObitFlowers.Rows.Count > 0) { //sets the flowers recipient in the sidebar dlFlowerRecipient.DataSource = dtObitFlowers; dlFlowerRecipient.DataBind(); }//end of if else //removes the 'or' flowers from view panFlowersOr.Visible = false; //checks if there is any cards if (dtObitCards != null && dtObitCards.Rows.Count > 0) { //sets the card recipient in the sidebar rpCardReceiver.DataSource = dtObitCards; rpCardReceiver.DataBind(); }//end of if else //removes the 'or' card from view panCardOr.Visible = false; //resets lblBirthDateAndPassingDate lblBirthDateAndPassingDate.Text = ""; //checks if there is a birth date if(!string.IsNullOrEmpty(dtObituaryDetails.Rows[0][""].ToString())) lblBirthDateAndPassingDate.Text += Convert.ToDateTime(dtObituaryDetails.Rows[0][""].ToString()).ToString("MMMM dd, yyyy"); //checks that there must be both a birth\death date for - to display if(!string.IsNullOrEmpty(dtObituaryDetails.Rows[0][""].ToString()) && !string.IsNullOrEmpty(dtObituaryDetails.Rows[0][""].ToString())) lblBirthDateAndPassingDate.Text += " - "; //checks if there is a death date or a is this a pre-plan obituarie if(!string.IsNullOrEmpty(dtObituaryDetails.Rows[0][""].ToString())) //sets the death year lblBirthDateAndPassingDate.Text += Convert.ToDateTime(dtObituaryDetails.Rows[0][""].ToString()).ToString("MMMM dd, yyyy"); //checks if there is any text in the lblBirthDateAndPassingDate //in order to add it to the print version if(!string.IsNullOrEmpty(lblBirthDateAndPassingDate.Text)) lblPrintBirthDateAndPassingDate.Text = lblBirthDateAndPassingDate.Text; //sets the twitter sharing for this obituery hlShareTwiiter.NavigateUrl = "https://twitter.com/share?url=" + Server.UrlEncode("http://theobituaries.ca/Obituaries.aspx?ObituariesID=" + hfObituaryID.Value) + "&text=Obituary for " + lblName.Text; //sets the linkin sharing for this obituery ltlLinkin.Text = "<script type='IN/Share' data-url='" + Server.UrlEncode("http://theobituaries.ca/Obituaries.aspx?ObituariesID=" + hfObituaryID.Value) + "'></script>"; //checks if strShareDescription has any content if(string.IsNullOrEmpty(strShareDescription)) //uses a default text as to not have DNN text display on the user's condolences strShareDescription = "A condolence for " + dtObituaryDetails.Rows[0][""].ToString() + " " + dtObituaryDetails.Rows[0][""].ToString(); //sets the Facebook sharing for this obituery litFB.Text = "<iframe src='http://www.facebook.com/plugins/like.php?href=http%3A%2F%2F" + Request.Url.Host + "%2FObituaries.aspx%3FObituariesID%3D" + hfObituaryID.Value + "&send=false&layout=button_count&width=60&show_faces=false&font&colorscheme=light&action=like&height=21&appId=574005609290762' scrolling='no' frameborder='0' style='overflow:hidden;height:21px;' allowTransparency='true'></iframe>"; HtmlMeta hmFB = new HtmlMeta();//holds the meta takes that will go into the header HtmlHead head = (HtmlHead)Page.Header;//holds the reference of the Header lnkSendCardToFuneralHome.Visible = false; if (dtObituaryDetails.Rows[0][""].ToString() == "True" && !string.IsNullOrEmpty(dtObituaryDetails.Rows[0][""].ToString()) && dtObituaryDetails.Rows[0][""].ToString() != "0") { lnkSendCardToFuneralHome.NavigateUrl = "/Obituaries/sympathycards.aspx?ObituariesID=" + hfObituaryID.Value + "&FuneralHomeID=" + dtObituaryDetails.Rows[0][""].ToString(); lnkSendCardToFuneralHome.Visible = true; }//end of if if (!string.IsNullOrEmpty(dtObituaryDetails.Rows[0][""].ToString())) hfObituaryCreatorEmail.Value = DAL.queryDbScalar("SELECT FROM WHERE = '" + dtObituaryDetails.Rows[0][""].ToString() + "'"); //resets litObituaryServices litObituaryServices.Text = ""; //checks if there is any sevices if(dtObitService.Rows.Count > 0) { //goes around adding the services of the Obituary foreach (DataRow drObitService in dtObitService.Rows) { //checks if there is a FHID or or is the different //this is different from the next one as this will skip the whole row if(Convert.ToInt32(drObitService[""].ToString()) != 0 || Convert.ToInt32(drObitService[""].ToString()) == 0 && strLastFHID != drObitService[""].ToString()) { //checks if the last FHID or is the different if(strLastFHID != drObitService[""].ToString() || Convert.ToInt32(drObitService[""].ToString()) == 0 && strLastFHID != drObitService[""].ToString()) { DataTable dtFHDetails = DAL.getRow("", "WHERE = " + Convert.ToInt32(drObitService[""].ToString()));//holds the Funeral Home details //checks if this is a the first service //as there is not last service yet if(!string.IsNullOrEmpty(strLastFHID)) //create a ends the last serivce litObituaryServices.Text += "</div>"; //starts a new one litObituaryServices.Text += "<div class='customContainer divObiturayDetailsServiceContainer'>" + "<div class='customLeft divObiturayDetailsServiceLeft'>"; //checks if this FH is in the database and if it is a partner if (dtFHDetails != null && dtFHDetails.Rows.Count > 0) { string strSearchItemMap = "";//holds the map of the search itme //checks if there is a address to search for the google map if(!string.IsNullOrEmpty(dtFHDetails.Rows[0][""].ToString()) && !string.IsNullOrEmpty(dtFHDetails.Rows[0][""].ToString()) && !string.IsNullOrEmpty(dtFHDetails.Rows[0][""].ToString())) { //checks if there is a already a location that the user wants to use if(dtFHDetails.Rows[0][""] == null || string.IsNullOrEmpty(dtFHDetails.Rows[0][""].ToString().Trim())) //adds the funcation that will activate the google map hidden strSearchItemMap = "getLocationHiddenGeo("" + dtFHDetails.Rows[0][""].ToString().Replace("'", "‘").Replace("\"", """) + "," + dtFHDetails.Rows[0][""].ToString().Replace("'", "‘").Replace("\"", """) + "," + dtFHDetails.Rows[0][""] + "","" + dtFHDetails.Rows[0][""].ToString().Replace("'", "‘").Replace("\"", """) + "",43.64100156269233,-79.38599562435303);"; else //adds funcation that will activate the google map hidden what the user want to display strSearchItemMap = "getLocationHiddenGeo("" + dtFHDetails.Rows[0][""].ToString().Replace("'", "‘").Replace("\"", """) + "," + dtFHDetails.Rows[0][""].ToString().Replace("'", "‘").Replace("\"", """) + "," + dtFHDetails.Rows[0][""] + "","" + dtFHDetails.Rows[0][""].ToString().Replace("'", "‘").Replace("\"", """) + ""," + dtFHDetails.Rows[0][""] + ");"; }//end of if //loads the ability to display the map if (panSidebarLinks.Visible) litObituaryServices.Text += "<a href='javascript:void(0);' onClick='" + strSearchItemMap + "toggleLayer("divHiddenHeaderMap","divGrayBG","");getDocID("lblHiddenMapName").innerHTML="Location for " + dtFHDetails.Rows[0][""].ToString().Replace("'", "‘").Replace("\"", """) + " - " + dtFHDetails.Rows[0][""].ToString().Replace("'", "‘").Replace("\"", """) + ", " + dtFHDetails.Rows[0][""].ToString() + "";'><img alt='Map' src='/Portals/_default/skins/Obit/Images/obits-map.jpg' /></a>"; else litObituaryServices.Text += "<img alt='Map' src='/Portals/_default/skins/Obit/Images/obits-map.jpg' />"; }//end of if //displays a custom FH that the user has create else litObituaryServices.Text += "<a href='javascript:void(0);' onClick='getLocationHiddenGeo("" + drObitService[""].ToString().Replace("'", "‘").Replace("\"", """) + "," + drObitService[""].ToString().Replace("'", "‘").Replace("\"", """) + "," + drObitService[""] + "","" + drObitService[""].ToString().Replace("'","‘").Replace("\"",""") + "",43.64100156269233,-79.38599562435303);toggleLayer("divHiddenHeaderMap","divGrayBG","");getDocID("lblHiddenMapName").innerHTML="Location for " + drObitService[""].ToString().Replace("'","‘").Replace("\"",""") + " - " + drObitService[""].ToString().Replace("'","‘").Replace("\"",""") + ", " + drObitService[""].ToString() + "";'><img alt='Map' src='/Portals/_default/skins/Obit/Images/obits-map.jpg' /></a>"; litObituaryServices.Text += "</div>" + "<div class='customRight divObiturayDetailsServiceRight'>"; //checks if this FH is in the database and if it is a partner if (dtFHDetails != null && dtFHDetails.Rows.Count > 0) { //checks if this is a Publish FH or non if (dtFHDetails.Rows[0][""].ToString() == "1" && panSidebarLinks.Visible) litObituaryServices.Text += "<a href='/FuneralHome.aspx?FuneralHomeId=" + dtFHDetails.Rows[0][""].ToString() + "'>" + dtFHDetails.Rows[0][""].ToString() + "</a>"; else litObituaryServices.Text += "<label class='lblObituaryFHServiceName'>" + dtFHDetails.Rows[0][""].ToString() + "</label>"; litObituaryServices.Text += "<div class='divObiturayServiceLocation'>" + dtFHDetails.Rows[0][""].ToString() + ", " + dtFHDetails.Rows[0][""].ToString() + ", " + dtFHDetails.Rows[0][""].ToString() + ", " + dtFHDetails.Rows[0][""].ToString() + "</div>"; }//end of if //displays a custom FH that the user has create else { //checks if there is a custom name for this custom FH if(!string.IsNullOrEmpty(drObitService[""].ToString())) litObituaryServices.Text += "<label class='lblObituaryFHServiceName'>" + drObitService[""].ToString() + "</label>" + "<div class='divObiturayServiceLocation'>"; else //beacuse divObiturayServiceLocation has a padding this will move //make the address not appeaeal with the map icon this wll fix it litObituaryServices.Text += "<div class='divObiturayServiceNoCustomLocationName'>"; litObituaryServices.Text += drObitService[""].ToString() + ", " + drObitService[""].ToString() + ", " + drObitService[""].ToString() + ", " + drObitService[""].ToString() + "</div>"; }//end of else //sets the link to open the location and start the service detail div litObituaryServices.Text += "<a href='#service-location-" + intIndexServiceID + "' class='toggle-location scroll-show'>Open Location</a>" + "</div>" + "<div class='customFooter divObiturayDetailsServiceFooter'></div>"; //checks if this row is a FH or a custom address //and then updates the strLastFHID if(Convert.ToInt32(drObitService[""].ToString()) == 0) strLastFHID = drObitService[""].ToString(); else strLastFHID = drObitService[""].ToString(); }//end of if //displays the details of the service litObituaryServices.Text += "<div class='divObiturayServiceDateTime'>" + "<div class='divObiturayServiceDate'>" + "<label>" + Convert.ToDateTime(drObitService[""].ToString()).ToString("dddd, MMMM d, yyyy") + "</label>" + "</div>" + "<div class='divObiturayServiceTime'>" + "<label><strong>"; //checks which Obituary Service Type is this and displays it switch(Convert.ToInt32(drObitService[""].ToString())) { case 0: litObituaryServices.Text += "Visitation"; break; case 1: litObituaryServices.Text += "Funeral Service"; break; case 2: litObituaryServices.Text += "Graveside Service"; break; case 3: litObituaryServices.Text += "Memorial Service"; break; case 4: litObituaryServices.Text += "Non Commemorative Funeral"; break; case 6: litObituaryServices.Text += "Celebration of Life"; break; default: litObituaryServices.Text += drObitService[""].ToString(); break; }//end of switch //displays the service start time litObituaryServices.Text += " - " + Convert.ToDateTime(drObitService[""].ToString()).ToString("h:mm tt"); //checks if there is a service end time if(!string.IsNullOrEmpty(drObitService[""].ToString()) && drObitService[""].ToString() != "00:00:00") //displays the service end time litObituaryServices.Text += " - " + Convert.ToDateTime(drObitService[""].ToString()).ToString("h:mm tt"); //end the details of the service litObituaryServices.Text += "</strong></label>" + "</div>" + "</div>"; intIndexServiceID++; }//end of if }//end of foreach //closes the last service litObituaryServices.Text += "</div>"; }//end of if else //remvoes the service section from display panObituaryServices.Visible = false; }//end of if //}//end of if }//end of try catch (Exception ex) { lblMainError.Text = ex.Message;// + " " + ex.StackTrace; lblMainError.Visible = true; }//end of catch }//end of Page_PreRender()
public static void TestTokenValidation() { OAuthTokens fakeTokens = new OAuthTokens(); TwitterStatus.Update(fakeTokens, "This shouldn't work"); }
private static void DeleteFriendship(OAuthTokens tokens, TwitterRelationship friendship) { var unfollowedUser = friendship.Delete(tokens); Assert.IsNotNull(unfollowedUser.ResponseObject, unfollowedUser.ErrorMessage); }
}//end of dlCondolence_ItemDataBound() protected void cmdSaveCondolonces_Click(object sender, EventArgs e) { try { lblConError.Text = string.Empty; lblConError.Visible = false; //checks if the page is valid if so then prcess the event if (Page.IsValid) { //checks if the Captcha is validated if (Captcha.Validate(txtCaptchaCode.Text.Trim().ToUpper())) { string strUserEmail = lblConnectedEmail.Text;//holds the users email address string strAddSubject = "condolences";//holds the and the condolences as they could be two ways of sending it public or private DataTable dtObitUsers = DAL.getRow("", "WHERE = " + hfObituaryID.Value);//gets all users that are either creators or co-owners //checks if there is a user email addres if the user has not loged in //and needs to type it out if (string.IsNullOrEmpty(strUserEmail)) strUserEmail = txtConEMail.Text; //checks if the user is log into the site if (Session[""] != null) //adds a new condolence with the user who is logged into the site DAL.addUpdateObituaryCondolence(0, Convert.ToInt32(hfObituaryID.Value), Convert.ToInt32(Session[""].ToString()), 0, "", "", txtConMessage.Text, "", chkPrivateCon.Checked); else { //checks if the user is logged into the site or soical site if (panConNameEmail.Visible == false) //adds a new condolence with the user who is not logged in DAL.addUpdateObituaryCondolence(0, Convert.ToInt32(hfObituaryID.Value), 0, 0, txtConName.Text, strUserEmail, txtConMessage.Text, "", chkPrivateCon.Checked); else { FacebookApp facebookApp = new FacebookApp();//holds an object of the FB //adds a new condolence with the user who is logged into soical site //for intObituaryCondolenceSocialNetwork /* 1 = FB 2 = Twitter 3 = Linkin 4 = Google */ DAL.addUpdateObituaryCondolence(0, Convert.ToInt32(hfObituaryID.Value), 0, Convert.ToInt32(hfObituaryCondolenceSocialNetwork.Value), lblConnectedName.Text, strUserEmail, txtConMessage.Text, lblConnectedUser.Text, chkPrivateCon.Checked); //checks if the user is connected to FB if (facebookApp.Session != null && facebookApp.AccessToken != null && chkPrivateCon.Checked == false) { var fb = new FacebookClient(facebookApp.AccessToken); //publish the user's public condolence to their FB wall dynamic result = fb.Post("me/feed", new { message = txtConMessage.Text, link = "http://" + Request.Url.Host + "/ObituaryDetailShare.aspx?id=" + hfObituaryID.Value }); }//end of if //tweets to the user else if (Request["oauth_token"] != null && chkPrivateCon.Checked == false) { var tokens = OAuthUtility.GetAccessToken( ConfigurationManager.AppSettings[""], ConfigurationManager.AppSettings[""], Session["TwitterRequestToken"].ToString(), Session["TwitterPin"].ToString()); OAuthTokens oatAccess = new OAuthTokens() { AccessToken = tokens.Token, AccessTokenSecret = tokens.TokenSecret, ConsumerKey = ConfigurationManager.AppSettings[""], ConsumerSecret = ConfigurationManager.AppSettings[""] }; TwitterResponse<TwitterStatus> tsResponse = TwitterStatus.Update(oatAccess, txtConMessage.Text); }//end of else if }//end of else }//end of else //checks if this is a Private Condolence for the admin send out if (chkPrivateCon.Checked == true) //changes the subject for the send out to the admin strAddSubject = "a Private Condolence"; //checks if there is a email if (!string.IsNullOrEmpty(hfObituaryCreatorEmail.Value)) //sends out email to creators sendCondolencesEmail(hfObituaryCreatorEmail.Value, "You have received " + strAddSubject, "send-condolence-nophoto", chkPrivateCon.Checked, true); //goes around send it to all user who are any coowners foreach (DataRow drObitUsers in dtObitUsers.Rows) { //checks if there is a email if (!string.IsNullOrEmpty(drObitUsers[""].ToString())) //sends out email to any coowners sendCondolencesEmail(drObitUsers[""].ToString(), "You have received " + strAddSubject, "send-condolence-nophoto", chkPrivateCon.Checked, true); }//end of for loop //checks if this is a Private Condolence for the user send out if (chkPrivateCon.Checked == true) { //changes the subject for private condolence strAddSubject = "PRIVATE Condolences"; //changes the thank you message for private condolence litThankYou.Text = "Your private condolence will be shared with the family. A copy has also been sent to your email address."; }//end of if //checks if there is a email to send to as if the user uses twitter it will be not avialable if (!string.IsNullOrEmpty(strUserEmail)) //sends out email to admin to send to user sendCondolencesEmail(strUserEmail, "Your " + strAddSubject + " have been sent", "send-condolence", chkPrivateCon.Checked); //resets the condolences, the number of them for this Obituary and paging //gets the number of condolences InitializePagingVars(true); //resets the condolences Bind(-1); //resets the paging contorls BindPagingControls(); //turns on the thank you message //panCondoloncesFourm.Visible = false; panCondoloncesThankYou.Visible = true; chkPrivateCon.Checked = false; txtCaptchaCode.Text = string.Empty; txtConName.Text = "Your Name *"; txtConEMail.Text = "Your Email Address *"; txtConMessage.Text = "Your Message *"; }//end of if else { lblConError.Text = "Invalid captcha!!"; lblConError.Visible = true; panCondoloncesThankYou.Visible = false; }//end of else }//end of if }//end of try catch (Exception ex) { lblConError.Text = ex.Message; lblConError.Visible = true; panCondoloncesThankYou.Visible = false; }//end of catch }//end of cmdSaveCondolonces_Click()
public InstagramDataProvider(string queryType, string query, OAuthTokens tokens) { _queryType = queryType; _query = query; _tokens = tokens; }
/// <summary> /// Initializes a new instance of the OAuthWebAuthCodeGrant class. /// </summary> /// <param name="clientId"> /// The client identifier corresponding to your registered application. /// </param> /// <param name="optionalClientSecret"> /// The client secret corresponding to your registered application, or null if your app is a desktop or mobile app. /// </param> /// <param name="redirectionUri"> /// The URI to which the user of the app will be redirected after receiving user consent. /// </param> /// <param name="oauthTokens"> /// Contains information about OAuth access tokens received from the Microsoft Account authorization service. /// </param> /// <param name="environment">Bing Ads API environment</param> /// <remarks> /// <para> /// For more information about using a client identifier for authentication, see /// <see href="https://tools.ietf.org/html/rfc6749#section-3.1">Client Password Authentication section of the OAuth 2.0 spec</see>. /// </para> /// <para> /// For web applications, redirectionUri must be within the same domain of your registered application. /// For more information, see <see href="https://tools.ietf.org/html/rfc6749#section-2.1.1">Redirection Uri section of the OAuth 2.0 spec</see>. /// </para> /// </remarks> protected OAuthWithAuthorizationCode(string clientId, string optionalClientSecret, Uri redirectionUri, OAuthTokens oauthTokens, ApiEnvironment?environment) : this(clientId, optionalClientSecret, redirectionUri, environment) { if (oauthTokens == null || oauthTokens.RefreshToken == null) { throw new ArgumentNullException("oAuthTokens"); } OAuthTokens = new OAuthTokens(null, 0, oauthTokens.RefreshToken, oauthTokens.ResponseFragments); }
public ResponseAction PostTwitter(PostToTwitterViewModel message) { ResponseAction rsp = new ResponseAction(); rsp.Success = true; bool trysended = false; List <TwitterAccountPart> TwitterAccountSettings = Twitter_GetAccessToken(message.AccountList); ProviderConfigurationRecord pcr = _providerConfigurationService.Get("Twitter"); foreach (TwitterAccountPart Faccount in TwitterAccountSettings) { try { trysended = true; OAuthTokens accesstoken = new OAuthTokens() { AccessToken = Faccount.UserToken, AccessTokenSecret = Faccount.UserTokenSecret, ConsumerKey = pcr.ProviderIdKey, ConsumerSecret = pcr.ProviderSecret }; TwitterResponse <TwitterStatus> response; string realmessage = message.Message; if (!string.IsNullOrEmpty(message.Link)) { realmessage += " " + message.Link; } if (string.IsNullOrEmpty(message.Picture)) { response = TwitterStatus.Update(accesstoken, realmessage.Trim()); } else { var mediaPath = HostingEnvironment.IsHosted ? HostingEnvironment.MapPath("~/Media/") ?? "" : Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Media"); string physicalPath = mediaPath + _shellsettings.Name + "\\" + message.Picture; byte[] photo = System.IO.File.ReadAllBytes(physicalPath); response = TwitterStatus.UpdateWithMedia(accesstoken, realmessage.Trim(), photo, new StatusUpdateOptions() { UseSSL = true, APIBaseAddress = "http://api.twitter.com/1.1/" }); } if (response.Result != RequestResult.Success) { if (response.Content != null) { Logger.Error("response.Content:" + response.Content); } rsp.Success = false; if (response.ErrorMessage != null) { Logger.Error("response.ErrorMessage:" + response.ErrorMessage); _notifier.Add(NotifyType.Error, T("Can't post on twitter: {0} {1}", Faccount.DisplayAs, response.ErrorMessage)); } else { var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); var jsondict = serializer.Deserialize <Dictionary <string, object> >(response.Content); ArrayList errors = (ArrayList)jsondict["errors"]; foreach (System.Collections.Generic.Dictionary <string, object> error in errors) { string errormsg = ""; foreach (var errordict in error) { errormsg += " " + errordict.Key.ToString() + ":" + errordict.Value.ToString(); } _notifier.Add(NotifyType.Error, T("Can't post on twitter: {0} {1}", Faccount.DisplayAs, errormsg)); } } } } catch (Exception ex) { Logger.Error("Twitter Posting Error Message::" + ex.Message); rsp.Success = false; rsp.Message = "Twitter Posting Error Message: " + ex.Message; _notifier.Add(NotifyType.Error, T("Twitter Posting {0} Error Message: {1}", Faccount.DisplayAs, ex.Message)); } } if (trysended && rsp.Success) { _notifier.Add(NotifyType.Information, T("Twitter posted")); } return(rsp); }
/// <summary> /// Initializes a new instance of the <see cref="BlockingCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> public BlockingCommand(OAuthTokens tokens, BlockingOptions options) : base(HttpMethod.Get, "blocks/blocking.json", tokens, options) { }
/// <summary> /// Initializes a new instance of the <see cref="UpdateProfileCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> public UpdateProfileCommand(OAuthTokens tokens, UpdateProfileOptions options) : base(HttpMethod.Post, "account/update_profile.json", tokens, options) { }
/// <summary> /// Initializes a new instance of the OAuthWithAuthorizationCode class. /// </summary> /// <param name="clientId"> /// The client identifier corresponding to your registered application. /// </param> /// <param name="optionalClientSecret"> /// The client secret corresponding to your registered application, or null if your app is a desktop or mobile app. /// </param> /// <param name="redirectionUri"> /// The URI to which the user of the app will be redirected after receiving user consent. /// </param> /// <param name="refreshToken"> /// The refresh token that should be used to request an access token. /// </param> /// <remarks> /// <para> /// For more information about using a client identifier for authentication, see /// <see href="http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-3.1">Client Password Authentication section of the OAuth 2.0 spec</see> /// </para> /// <para> /// For web applications, redirectionUri must be within the same domain of your registered application. /// For more information, see <see href="http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-2.1.1">Redirection Uri section of the OAuth 2.0 spec</see>. /// </para> /// </remarks> protected OAuthWithAuthorizationCode(string clientId, string optionalClientSecret, Uri redirectionUri, string refreshToken) : this(clientId, optionalClientSecret, redirectionUri, new LiveComOAuthService()) { if (refreshToken == null) { throw new ArgumentNullException("refreshToken"); } OAuthTokens = new OAuthTokens(null, 0, refreshToken); }
internal static string ExecuteAuthenticatedWebRequestPost(string twitterQuery, OAuthTokens tokens, bool retry = true) { //get mentions string responseText = string.Empty; WebResponse response; try { WebRequestBuilder requestBuilder = new WebRequestBuilder(new Uri(twitterQuery), HTTPVerb.POST, tokens); requestBuilder.Multipart = true; response = requestBuilder.ExecuteRequest(); if (!Object.Equals(response, null)) { responseText = BuildTextFromResponse(response); if (string.IsNullOrEmpty(responseText)) { ExceptionExtensions.LogWarning(new ArgumentNullException("Twitter responseText from the httpwebresponse was empty"), "Twitter ExecuteAuthenticatedWebRequestPost", "Query: " + twitterQuery); } } else { ExceptionExtensions.LogWarning(new ArgumentNullException("Twitter httwebresponse object was null"), "Twitter ExecuteAuthenticatedWebRequestPost", "Query: " + twitterQuery); } } catch (Exception e) { if (e.Message.Contains("404") || e.Message.Contains("502")) { Thread.Sleep(1000); ExecuteAuthenticatedWebRequestPost(twitterQuery, tokens, true); } else { ExceptionExtensions.LogError(e, "Drone.API.Twitter.Request.ExecuteAuthenticatedWebRequestPOST", twitterQuery); } } return(responseText); }
/// <summary> /// Blocks the user and reports them for spam/abuse. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="screenName">The user's screen name.</param> /// <param name="options">The options.</param> /// <returns>The user details.</returns> public static TwitterResponse<TwitterUser> ReportUser(OAuthTokens tokens, string screenName, OptionalProperties options) { Commands.ReportSpamCommand command = new Commands.ReportSpamCommand(tokens, 0, screenName, options); return Core.CommandPerformer.PerformAction(command); }
/// <summary> /// Renew the OAuth tokens required to access the cloud based API (Synchronous) /// </summary> /// <param name="oauthTokens">The tokens that are required to access the user's company files</param> /// <returns></returns> public Task <OAuthTokens> RenewTokensAsync(OAuthTokens oauthTokens) { return(this.RenewTokensAsync(oauthTokens, CancellationToken.None)); }
/// <include file='TwitterUser.xml' path='TwitterUser/Show[@name="Common"]/*'/> /// <include file='TwitterUser.xml' path='TwitterUser/Show[@name="ByUsernameWithTokensAndOptions"]/*'/> public static async Task<TwitterResponse<TwitterUser>> ShowAsync(string username, OAuthTokens tokens = null, OptionalProperties options = null) { return await Core.CommandPerformer.PerformAction(new Commands.ShowUserCommand(tokens, 0, username, options)); }
/// <summary> /// Initializes a new instance of the <see cref="PublicTimelineCommand"/> class. /// </summary> /// <param name="tokens">The request tokens.</param> /// <param name="options">The options.</param> public PublicTimelineCommand(OAuthTokens tokens, OptionalProperties options) : base(HTTPVerb.GET, "statuses/public_timeline.json", tokens, options) { }
public ActionResult Profile(String screenname) { if (Session["LoggedASP"] != null) { ViewData["username"] = ((User)Session["LoggedUser"]).Username; } try { TwitterResponse <TwitterUser> user; if (Session["LoggedTwitter"] != null) { OAuthTokens token = new OAuthTokens(); token.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"]; token.ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"]; token.AccessToken = ((User)Session["LoggedUser"]).TwitterToken; token.AccessTokenSecret = ((User)Session["LoggedUser"]).TwitterTokenSecret; user = TwitterUser.Show(token, screenname); } else { user = TwitterUser.Show(screenname); } if (String.IsNullOrEmpty(user.ErrorMessage)) { ViewData["content"] = "<img class='userImg' src='" + user.ResponseObject.ProfileImageLocation.ToString() + "' />Profil de <em>@" + user.ResponseObject.ScreenName + "</em> qui possède l'ID N°" + user.ResponseObject.Id + "<br />Il s'est enregistré sur Twitter le : " + user.ResponseObject.CreatedDate + " et il possède " + user.ResponseObject.NumberOfFollowers + " followers."; UserTimelineOptions options = new UserTimelineOptions(); options.ScreenName = screenname; options.Count = 100; options.IncludeRetweets = true; if (Session["LoggedTwitter"] != null) { OAuthTokens token = new OAuthTokens(); token.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"]; token.ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"]; token.AccessToken = ((User)Session["LoggedUser"]).TwitterToken; token.AccessTokenSecret = ((User)Session["LoggedUser"]).TwitterTokenSecret; bool taRaceVanStaen = false; if (screenname.ToLower() == TwitterUser.Show(token, Decimal.Parse(((User)Session["LoggedUser"]).TwitterID)).ResponseObject.ScreenName.ToLower()) { taRaceVanStaen = false; } TwitterResponse <TwitterStatusCollection> truc = TwitterTimeline.UserTimeline(token, options); if (String.IsNullOrEmpty(truc.ErrorMessage)) { foreach (var item in truc.ResponseObject) { if (taRaceVanStaen) { ViewData["tweets"] += "<div class='editTweet'><a href=''>Edit</a> <a href=''>Delete</a></div><div><a href=\"/User/" + item.User.ScreenName + "\">" + item.User.ScreenName + "</a> ---- " + item.Text.Replace("\n", "<br />").ToString() + "</div>"; } else { ViewData["tweets"] += "<div><a href=\"/User/" + item.User.ScreenName + "\">" + item.User.ScreenName + "</a> ---- " + item.Text.Replace("\n", "<br />").ToString() + "</div>"; } } } else { ViewData["tweets"] = "Les tweets de cet utilisateur sont protégés."; } } else { TwitterResponse <TwitterStatusCollection> truc = TwitterTimeline.UserTimeline(options); if (String.IsNullOrEmpty(truc.ErrorMessage)) { foreach (var item in truc.ResponseObject) { ViewData["tweets"] += "<div><a href=\"/User/" + item.User.ScreenName + "\">" + item.User.ScreenName + "</a> ---- " + item.Text.Replace("\n", "<br />").ToString() + "</div>"; } } else { ViewData["tweets"] = "Les tweets de cet utilisateur sont protégés."; } } return(View("Index")); } else { ViewData["errorMessage"] = user.ErrorMessage; return(View("Error")); } } catch (Exception exception) { ViewData["errorMessage"] = exception.Message; return(View("Error")); } }
/// <summary> /// Blocks the user and reports them for spam/abuse. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="userId">The user id.</param> /// <param name="options">The options.</param> /// <returns>The user details.</returns> public static TwitterResponse <TwitterUser> ReportUser(OAuthTokens tokens, decimal userId, OptionalProperties options) { Commands.ReportSpamCommand command = new Commands.ReportSpamCommand(tokens, userId, string.Empty, options); return(Core.CommandPerformer.PerformAction(command)); }
/// <summary> /// Returns the numeric IDs for every user the specified user is friends with. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options. Leave null for defaults.</param> /// <returns> /// A <see cref="TwitterListCollection"/> instance. /// </returns> public static async Task<TwitterResponse<UserIdCollection>> FriendsIdsAsync(OAuthTokens tokens, UsersIdsOptions options = null) { return await Core.CommandPerformer.PerformAction(new Commands.FriendsIdsCommand(tokens, options)); }
/// <summary> /// Blocks the user and reports them for spam/abuse. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="userId">The user id.</param> /// <returns>The user details.</returns> public static TwitterResponse <TwitterUser> ReportUser(OAuthTokens tokens, decimal userId) { return(ReportUser(tokens, userId, null)); }
/// <summary> /// Initializes a new instance of the <see cref="WebRequestBuilder"/> class. /// </summary> /// <param name="requestUri">The request URI.</param> /// <param name="verb">The verb.</param> /// <param name="tokens">The tokens.</param> /// <param name="userAgent">The user agent.</param> public WebRequestBuilder(Uri requestUri, HttpMethod verb, OAuthTokens tokens, string userAgent = "") : this(requestUri, verb, userAgent, null) { this.Tokens = tokens; if (tokens != null) { if (string.IsNullOrEmpty(this.Tokens.ConsumerKey) || string.IsNullOrEmpty(this.Tokens.ConsumerSecret)) { throw new ArgumentException("Consumer key and secret are required for OAuth requests."); } if (string.IsNullOrEmpty(this.Tokens.AccessToken) ^ string.IsNullOrEmpty(this.Tokens.AccessTokenSecret)) { throw new ArgumentException("The access token is invalid. You must specify the key AND secret values."); } this.UseOAuth = true; } }
/// <summary> /// Blocks the user and reports them for spam/abuse. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="screenName">The user's screen name.</param> /// <param name="options">The options.</param> /// <returns>The user details.</returns> public static TwitterResponse <TwitterUser> ReportUser(OAuthTokens tokens, string screenName, OptionalProperties options) { Commands.ReportSpamCommand command = new Commands.ReportSpamCommand(tokens, 0, screenName, options); return(Core.CommandPerformer.PerformAction(command)); }
/// <summary> /// Enables device notifications for updates from the specified user. Returns the specified user when successful. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="screenName">The user's screen name.</param> /// <param name="options">The options.</param> /// <returns></returns> public static TwitterResponse<TwitterUser> Follow(OAuthTokens tokens, string screenName, OptionalProperties options) { Commands.NotificationFollowCommand command = new Commands.NotificationFollowCommand(tokens, 0, screenName, options); return Core.CommandPerformer.PerformAction(command); }
/// <summary> /// Initializes a new instance of the OAuthWebAuthCodeGrant class. /// </summary> /// <param name="clientId"> /// The client identifier corresponding to your registered application. /// </param> /// <param name="optionalClientSecret"> /// The client secret corresponding to your registered application, or null if your app is a desktop or mobile app. /// </param> /// <param name="redirectionUri"> /// The URI to which the user of the app will be redirected after receiving user consent. /// </param> /// <param name="oauthTokens"> /// Contains information about OAuth access tokens received from the Microsoft Account authorization service. /// </param> /// <remarks> /// <para> /// For more information about using a client identifier for authentication, see /// <see href="http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-3.1">Client Password Authentication section of the OAuth 2.0 spec</see>. /// </para> /// <para> /// For web applications, redirectionUri must be within the same domain of your registered application. /// For more information, see <see href="http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-2.1.1">Redirection Uri section of the OAuth 2.0 spec</see>. /// </para> /// </remarks> protected OAuthWithAuthorizationCode(string clientId, string optionalClientSecret, Uri redirectionUri, OAuthTokens oauthTokens) : this(clientId, optionalClientSecret, redirectionUri, new LiveComOAuthService()) { if (oauthTokens == null || oauthTokens.RefreshToken == null) { throw new ArgumentNullException("oAuthTokens"); } OAuthTokens = new OAuthTokens(null, 0, oauthTokens.RefreshToken); }
public ActionResult GetPostTokenTwitter() { var pcr = _providerConfigurationService.Get("Twitter"); if (pcr == null) { _notifier.Add(NotifyType.Error, T("No twitter account setting added, add one in Settings -> Open Authentication")); return(RedirectToAction("Index", "TwitterAccount", new { area = "Laser.Orchard.Twitter", id = -10 })); } string consumerKey = pcr.ProviderIdKey; string consumerSecret = pcr.ProviderSecret; // il meccanismo utilizzato è il 3-Legged oAuth if (Request["oauth_token"] == null) { string tmpreq = Request.Url.AbsoluteUri; OAuthTokenResponse reqToken = OAuthUtility.GetRequestToken(consumerKey, consumerSecret, tmpreq); Response.Redirect(string.Format("https://api.twitter.com/oauth/authorize?oauth_token={0}", reqToken.Token)); } else { string requestToken = Request["oauth_token"].ToString(); string verifier = Request["oauth_verifier"].ToString(); var tokens = OAuthUtility.GetAccessToken(consumerKey, consumerSecret, requestToken, verifier); TwitterAccountVM vm = new TwitterAccountVM(); vm.DisplayAs = tokens.ScreenName; vm.UserToken = tokens.Token; vm.UserTokenSecret = tokens.TokenSecret; // conterrà l'account_token_secret #region [recupero immagine] OAuthTokens accessToken = new OAuthTokens(); accessToken.AccessToken = vm.UserToken; accessToken.AccessTokenSecret = vm.UserTokenSecret; accessToken.ConsumerKey = consumerKey; accessToken.ConsumerSecret = consumerSecret; TwitterResponse <TwitterUser> myTwitterUser = TwitterUser.Show(accessToken, tokens.ScreenName); TwitterUser user = myTwitterUser.ResponseObject; var profilePictureUrl = user.ProfileImageLocation; var mediaPath = HostingEnvironment.IsHosted ? HostingEnvironment.MapPath("~/Media/") ?? "" : Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Media"); WebClient webClient = new WebClient(); webClient.DownloadFile(profilePictureUrl, mediaPath + _shellSettings.Name + @"\twitter_" + vm.DisplayAs + ".jpg"); #endregion // var avatarFormat = "https://api.twitter.com/1.1/users/show.json?screen_name={0}"; // var avatarUrl = string.Format(avatarFormat, vm.DisplayAs); // HttpWebRequest avatarRequest = (HttpWebRequest)WebRequest.Create(avatarUrl); // var timelineHeaderFormat = "{0} {1}"; // avatarRequest.Headers.Add("Authorization", String.Format("Bearer {0}", vm.UserToken)); //// avatarRequest.Headers.Add("Authorization", //// string.Format(timelineHeaderFormat, "oauth_token", requestToken)); // avatarRequest.Method = "Get"; // WebResponse timeLineResponse = avatarRequest.GetResponse(); // var reader = new StreamReader(timeLineResponse.GetResponseStream()); // var avatarJson = string.Empty; //using (authResponse) { // using (var reader = new StreamReader(timeLineResponse.GetResponseStream())) { // avatarJson = reader.ReadToEnd(); // } //} // Uri profilePictureUrl = new Uri(string.Format("https://api.twitter.com/1.1/users/show.json?screen_name={1}", vm.DisplayAs )); OrchardRegister(vm); } return(RedirectToAction("Index", "TwitterAccount", new { area = "Laser.Orchard.Twitter", id = -10 })); }
/// <summary> /// Initializes a new instance of the <see cref="TwitterStream"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="userAgent">The useragent string which shall include the version of your client.</param> /// <param name="streamoptions">The stream or user stream options to intially use when starting the stream.</param> public TwitterStream(OAuthTokens tokens, string userAgent, StreamOptions streamoptions) { #if !SILVERLIGHT // No non-silverlight user-agent as Assembly.GetName() isn't supported and setting the request.UserAgent is also not supported. if (string.IsNullOrEmpty(userAgent)) { this.UserAgent = string.Format( CultureInfo.InvariantCulture, "Twitterizer/{0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version); } else { this.UserAgent = string.Format( CultureInfo.InvariantCulture, "{0} (via Twitterizer/{1})", userAgent, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version); } #endif this.Tokens = tokens; if (streamoptions != null) this.StreamOptions = streamoptions; }
/// <summary> /// Adds the OAuth Echo header to the supplied web request. /// </summary> /// <param name="request">The request.</param> /// <param name="tokens">The tokens.</param> public static HttpRequestMessage AddOAuthEchoHeader(HttpRequestMessage request, OAuthTokens tokens) { WebRequestBuilder builder = new WebRequestBuilder( new Uri("https://api.twitter.com/1/account/verify_credentials.json"), HttpMethod.Post, tokens); builder.PrepareRequest(); request.Headers.Add("X-Verify-Credentials-Authorization", builder.GenerateAuthorizationHeader()); request.Headers.Add("X-Auth-Service-Provider", "https://api.twitter.com/1/account/verify_credentials.json"); return request; }
/// <summary> /// Blocks the user and reports them for spam/abuse. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="userId">The user id.</param> /// <param name="options">The options.</param> /// <returns>The user details.</returns> public static TwitterResponse<TwitterUser> ReportUser(OAuthTokens tokens, decimal userId, OptionalProperties options) { Commands.ReportSpamCommand command = new Commands.ReportSpamCommand(tokens, userId, string.Empty, options); return Core.CommandPerformer.PerformAction(command); }
/// <summary> /// Blocks the user and reports them for spam/abuse. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="screenName">The user's screen name.</param> /// <returns>The user details.</returns> public static TwitterResponse <TwitterUser> ReportUser(OAuthTokens tokens, string screenName) { return(ReportUser(tokens, screenName, null)); }
public void ProcessRequest(HttpContext context) { StringBuilder log = new StringBuilder(); string screenName = ""; try { string query = ""; UriBuilder urlBuilder = new UriBuilder("https://api.twitter.com/" + context.Server.UrlDecode(context.Request.QueryString["query"])); // Adds query strings to the url. // some headers may not be copied because they can't be used with clients other than twitter foreach (var queryString in context.Request.QueryString.AllKeys) { switch (queryString) { case "u": case "p": case "query": case "earned": case "pc": break; default: query += string.Format("&{0}={1}", queryString, context.Request.QueryString[queryString]); break; } } if (query.Length > 1) { query = query.Substring(1); } urlBuilder.Query = query; log.AppendLine(query); log.AppendLine("URL: " + urlBuilder.Uri.ToString()); OAuthTokens tokens = new OAuthTokens(); tokens.ConsumerKey = ConfigurationManager.AppSettings["TwitterConsumerKey"]; tokens.ConsumerSecret = ConfigurationManager.AppSettings["TwitterConsumerSecret"]; JToken accessToken; String userFileName = context.Server.MapPath("/App_Data/Users/" + context.Request.QueryString["u"] + "." + context.Request.QueryString["p"]); if (File.Exists(userFileName)) { using (StreamReader str = new StreamReader(userFileName)) { accessToken = JObject.Parse(str.ReadToEnd()); ; } tokens.AccessToken = (string)accessToken.SelectToken("AccessToken"); tokens.AccessTokenSecret = (string)accessToken.SelectToken("AccessSecret"); screenName = (string)accessToken.SelectToken("ScreenName"); log.AppendLine("User FOUND!"); } else { log.AppendLine("User NOT FOUND"); context.Response.StatusCode = 404; return; } //check if the request is xAuth, if it is, simulates the xAuth result for fooling Twitter for iPhone. if (context.Request.QueryString["query"].Contains("oauth/access_token")) { string xAuthResponse = string.Format("oauth_token={0}&oauth_token_secret={1}&user_id={2}&screen_name={3}&x_auth_expires=0", (string)accessToken.SelectToken("AccessToken"), (string)accessToken.SelectToken("AccessSecret"), (string)accessToken.SelectToken("UserId"), (string)accessToken.SelectToken("ScreenName")); context.Response.Write(xAuthResponse); screenName = (string)accessToken.SelectToken("ScreenName"); return; } HTTPVerb verb = HTTPVerb.GET; switch (context.Request.HttpMethod) { case "GET": verb = HTTPVerb.GET; break; case "POST": verb = HTTPVerb.POST; break; case "DELETE": verb = HTTPVerb.DELETE; break; } if (context.Request.Headers["Authorization"] == null) { tokens = null; log.AppendLine("Request NOT authenticated"); } WebRequestBuilder webreq = new WebRequestBuilder(urlBuilder.Uri, verb, tokens); webreq.Multipart = (context.Request.ContentType.Contains("multipart")); if (verb != HTTPVerb.GET) { // adds body parameters to request foreach (var key in context.Request.Form.AllKeys) { webreq.Parameters.Add(key, context.Request.Form[key]); } foreach (var fileKey in context.Request.Files.AllKeys) { webreq.Parameters.Add(fileKey, context.Request.Form[fileKey]); } } ServicePointManager.Expect100Continue = false; HttpWebRequest req = webreq.PrepareRequest(); try { HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); log.AppendLine("get Response"); StreamReader strReader = new StreamReader(resp.GetResponseStream()); String response = strReader.ReadToEnd(); if (ConfigurationManager.AppSettings["debugMode"] == "true") { log.AppendLine(response); } // replaces images url to use TwiX to load them response = Regex.Replace(response, @"(((http:\\/\\/www)|(http:\\/\\/)|(https:\\/\\/www)|(https:\\/\\/)|(www))[-a-zA-Z0-9@:%_\\\+.~#?&//=]+)\.(jpg|jpeg|gif|png|bmp|tiff|tga|svg)", delegate(Match match) { string v = match.ToString(); return(ConfigurationManager.AppSettings["baseUrl"] + "image/" + shFunctions.encryptBase64Url(DES.Encrypt(v.Replace(@"\/", "/").Replace("_normal", ""), shFunctions.key) + ".jpg")); }); strReader.Close(); context.Response.ClearContent(); context.Response.Write(response); } catch (WebException webex) { if (webex.Status == WebExceptionStatus.ProtocolError) { context.Response.StatusCode = (int)((HttpWebResponse)webex.Response).StatusCode; } log.AppendLine("ERROR: " + webex.Message); return; } } catch (Exception ee) { log.AppendLine("Error: " + ee.Message); log.AppendLine("stack: " + ee.StackTrace); } if (ConfigurationManager.AppSettings["log"] == "true") { writeLogToFile(log.ToString(), screenName, context.Request.HttpMethod, context); } //throw new Exception(context.Request.QueryString.ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="RateLimitStatusCommand"/> class. /// </summary> /// <param name="requestTokens">The request tokens.</param> /// <param name="options">The options.</param> public VerifyCredentialsCommand(OAuthTokens requestTokens, VerifyCredentialsOptions options) : base(HTTPVerb.GET, "account/verify_credentials.json", requestTokens, options) { }
/// <summary> /// Initializes a new instance of the <see cref="RateLimitStatusCommand"/> class. /// </summary> /// <param name="requestTokens">The request tokens.</param> /// <param name="options">The options.</param> public VerifyCredentialsCommand(OAuthTokens requestTokens, VerifyCredentialsOptions options) : base(HttpMethod.Get, "account/verify_credentials.json", requestTokens, options) { }
/// <include file='TwitterUser.xml' path='TwitterUser/Show[@name="Common"]/*'/> /// <include file='TwitterUser.xml' path='TwitterUser/Show[@name="ByIDWithTokensAndOptions"]/*'/> public static async Task<TwitterResponse<User>> ShowAsync(decimal id, OAuthTokens tokens = null, OptionalProperties options = null) { return await Core.CommandPerformer.PerformAction(new Commands.ShowUserCommand(tokens, id, string.Empty, options)); }
/// <summary> /// Initializes a new instance of the <see cref="BlockingCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> public BlockingCommand(OAuthTokens tokens, BlockingOptions options) : base(HTTPVerb.GET, "blocks/blocking.json", tokens, options) { }
/// <summary> /// Blocks the user and reports them for spam/abuse. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="userId">The user id.</param> /// <returns>The user details.</returns> public static TwitterResponse<TwitterUser> ReportUser(OAuthTokens tokens, decimal userId) { return ReportUser(tokens, userId, null); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { participantList.ItemsSource = participants; PasswordVault vault = new PasswordVault(); PasswordCredential credential = null; try { credential = vault.Retrieve("mixer.com", "MixerInteractive.UWP.Demo"); } catch { } if (credential == null) { debugText.Text = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().AbsoluteUri; Debug.WriteLine(WebAuthenticationBroker.GetCurrentApplicationCallbackUri().AbsoluteUri); var client = new OAuthClient( new OAuthOptions { ClientId = "17a72898b684d1f99652476c0a959638d2b735cdfad9e843", Scopes = new[] { "interactive:robot:self" }, }); // Use the helper GrantAsync to get codes. Alternately, you can run // the granting/polling loop manually using client.GetSingleCodeAsync. _tokens = await client.GrantAsync( code => { Debug.WriteLine($"Go to mixer.com/go and enter {code}"); var dialog = new MessageDialog($"Go to mixer.com/go and enter {code}", code); _ = dialog.ShowAsync(); }, CancellationToken.None); vault.Add(new PasswordCredential("mixer.com", "MixerInteractive.UWP.Demo", Newtonsoft.Json.JsonConvert.SerializeObject(_tokens))); } else { credential.RetrievePassword(); _tokens = Newtonsoft.Json.JsonConvert.DeserializeObject <OAuthTokens>(credential.Password); } //var result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, new Uri($"https://mixer.com/oauth/authorize?response_type=token&redirect_uri={WebAuthenticationBroker.GetCurrentApplicationCallbackUri().AbsoluteUri}&scope=interactive:robot:self&client_id=17a72898b684d1f99652476c0a959638d2b735cdfad9e843"),WebAuthenticationBroker.GetCurrentApplicationCallbackUri()); _gameClient = new GameClient(); _gameClient.OpenObs.Subscribe(_ => { Debug.WriteLine("GameClient opened!"); }); await _gameClient.OpenAsync(new GameClientOptions { AuthToken = _tokens.AccessToken, VersionId = 475488 }); _gameClient.State.OnParticipantJoin.Subscribe(participant => { participants.Add(participant); }); _gameClient.State.OnParticipantLeave.Subscribe(participant => { var found = participants.FirstOrDefault(x => x.SessionID == participant.SessionID); if (found != null) { participants.Remove(found); } }); debugText.Text = "Opened"; var state = await _gameClient.SynchronizeStateAsync(); debugText.Text = "State Synchronized"; await _gameClient.ReadyAsync(); debugText.Text = "Ready"; await _gameClient.CreateGroupsAsync(CreateGroups()); RegisterEvents(state.Item2); base.OnNavigatedTo(e); }
/// <summary> /// Blocks the user and reports them for spam/abuse. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="screenName">The user's screen name.</param> /// <returns>The user details.</returns> public static TwitterResponse<TwitterUser> ReportUser(OAuthTokens tokens, string screenName) { return ReportUser(tokens, screenName); }
/// <summary> /// Initializes a new instance of the <see cref="DestroyListSubscriber"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="listId">The list id.</param> /// <param name="options">The options.</param> /// <remarks></remarks> public DestroyListSubscriber(OAuthTokens tokens, decimal listId, OptionalProperties options) : base(HttpMethod.Post, "lists/subscribers/destroy.json", tokens, options) { this.ListId = listId; }
/// <include file='TwitterUser.xml' path='TwitterUser/Search[@name="Common"]/*'/> /// <include file='TwitterUser.xml' path='TwitterUser/Search[@name="WithTokensAndOptions"]/*'/> public static async Task<TwitterResponse<TwitterUserCollection>> SearchAsync(string query, OAuthTokens tokens = null, UserSearchOptions options = null) { return await Core.CommandPerformer.PerformAction(new Commands.UserSearchCommand(tokens, query, options)); }
public UserView(string UserScreenName, OAuthTokens oau) { InitializeComponent(); scr = UserScreenName; oa = oau; }
/// <summary> /// Initializes a new instance of the <see cref="UpdateProfileCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> public UpdateProfileCommand(OAuthTokens tokens, UpdateProfileOptions options) : base(HTTPVerb.POST, "account/update_profile.json", tokens, options) { }
public bool PostTwitter() { string resultID = hdnSelectedMessageID.Value; string requestCode = string.Empty; if (Session[TwitterCodeSessionKey] != null) { requestCode = Session[TwitterCodeSessionKey].ToString(); } if (requestCode == null) { Session[MessageKey] = txtFeedContent.Text.Trim(); //Session[TitleKey] = txtTitle.Text.Trim(); Session[ShareCodeType] = "Twitter"; OAuthTokenResponse reqToken = OAuthUtility.GetRequestToken( TwitterConsumerKey, TwitterConsumerSecret, Request.Url.AbsoluteUri); string url = string.Format("http://twitter.com/oauth/authorize?oauth_token={0}", reqToken.Token); Response.Redirect(url, false); } else { string requestToken = Session[TwitterCodeSessionKey].ToString(); string pin = Session[TwitterAuthVerifierSessionKey].ToString(); var tokens = OAuthUtility.GetAccessToken( TwitterConsumerKey, TwitterConsumerSecret, requestToken, pin); OAuthTokens accesstoken = new OAuthTokens() { AccessToken = tokens.Token, AccessTokenSecret = tokens.TokenSecret, ConsumerKey = TwitterConsumerKey, ConsumerSecret = TwitterConsumerSecret }; TwitterResponse <TwitterStatus> response = TwitterStatus.Update( accesstoken, txtFeedContent.Text.Trim()); if (response != null && response.Result == RequestResult.Success) { SocialFeedController feedController = new SocialFeedController(); UserChoiceInfo userChoiceInfo = feedController.ConvertToUserChoice(response, txtFeedContent.Text, resultID); int output = feedController.SaveUserChoice(userChoiceInfo); if (output == 1) { return(true); } else { return(false); } } else { if (response != null) { twitterCallBackContent = response.Content; } } } return(false); }