/// <summary> /// Sets one or more hex values that control the color scheme of the authenticating user's profile page on twitter.com. /// </summary> /// <param name="oAuth"></param> /// <param name="profile_background_color">Profile background color.</param> /// <param name="profile_link_color">Profile link color.</param> /// <param name="profile_sidebar_border_color">Profile sidebar's border color.</param> /// <param name="profile_sidebar_fill_color">Profile sidebar's background color.</param> /// <param name="profile_text_color">Profile text color.</param> /// <param name="include_entities">The entities node will not be included when set to false.</param> /// <param name="skip_status">When set to either true, t or 1 statuses will not be included in the returned user objects.</param> /// <returns></returns> public JArray Post_Account_Update_Profile_Colors(oAuthTwitter oAuth, string profile_background_color, string profile_link_color, string profile_sidebar_border_color, string profile_sidebar_fill_color, string profile_text_color, bool include_entities, bool skip_status, bool use) { string RequestUrl = Globals.PostAccountUpdateProfileColorUrl; SortedDictionary <string, string> strdic = new SortedDictionary <string, string>(); strdic.Add("include_entities", include_entities.ToString()); strdic.Add("skip_status", skip_status.ToString()); strdic.Add("&use", use.ToString()); if (profile_background_color != null) { strdic.Add("profile_background_color", profile_background_color); } if (profile_link_color != null) { strdic.Add("profile_link_color", profile_link_color); } if (profile_sidebar_border_color != null) { strdic.Add("profile_sidebar_border_color", profile_sidebar_border_color); } if (profile_sidebar_fill_color != null) { strdic.Add("profile_sidebar_fill_color", profile_sidebar_fill_color); } if (profile_text_color != null) { strdic.Add("profile_text_color", profile_text_color); } string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, RequestUrl, strdic); if (!response.StartsWith("[")) { response = "[" + response + "]"; } return(JArray.Parse(response)); }
/// <summary> /// This Method Will Check That User is Authenticated Or Not Using OAUTH /// </summary> /// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <returns>Return Xml Text With User Details</returns> public XmlDocument Verify_Credentials(oAuthTwitter OAuth) { string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, Globals.VerifyCredentialsUrl, String.Empty); xmlResult.Load(new StringReader(response)); return(xmlResult); }
//#region OAuth ///// <summary> ///// This Method Will Check That User is Authenticated Or Not Using OAUTH ///// </summary> ///// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> ///// <returns>Return Xml Text With User Details</returns> //public XmlDocument Verify_Credentials(oAuthTwitter OAuth) //{ // string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, Globals.VerifyCredentialsUrl, String.Empty); // xmlResult.Load(new StringReader(response)); // return xmlResult; //} /// <summary> /// This method Will Check Rate Limit Of Account Using OAUTH /// </summary> /// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <returns>Return Xml Text With User Details</returns> public XmlDocument Rate_Limit_Status(oAuthTwitter OAuth, SortedDictionary <string, string> strdic) { string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, Globals.RateLimitStatusUrl, strdic); xmlResult.Load(new StringReader(response)); return(xmlResult); }
private void GetUserDetailsFromTwitter() { if (Request["oauth_token"] != null & Request["oauth_verifier"] != null) { imgTwitter.Visible = false; tbleTwitInfo.Visible = true; var oAuth = new oAuthTwitter(); //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); XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(xml); XmlNodeList xmlList = xmldoc.SelectNodes("/user"); foreach (XmlNode node in xmlList) { name = node["name"].InnerText; username = node["screen_name"].InnerText; profileImage = node["profile_image_url"].InnerText; followersCount = node["followers_count"].InnerText; noOfTweets = node["statuses_count"].InnerText; recentTweet = node["status"]["text"].InnerText; } } } }
public static bool FollowAccount(string AccessToken, string AccessTokenSecret, string Screen_name, string user_id) { bool IsFollowed = false; oAuthTwitter oauth = new oAuthTwitter(); oauth.AccessToken = AccessToken; oauth.AccessTokenSecret = AccessTokenSecret; oauth.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"]; oauth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"]; string RequestUrl = "https://api.twitter.com/1.1/friendships/create.json"; SortedDictionary <string, string> strdic = new SortedDictionary <string, string>(); if (!string.IsNullOrEmpty(Screen_name)) { strdic.Add("screen_name", Screen_name); } else if (!string.IsNullOrEmpty(user_id)) { strdic.Add("user_id", user_id); } else { return(false); } strdic.Add("follow", "true"); string response = oauth.oAuthWebRequest(oAuthTwitter.Method.POST, RequestUrl, strdic); if (!string.IsNullOrEmpty(response)) { IsFollowed = true; } return(IsFollowed); }
/// <summary> /// Updates the authenticating user's profile background image. T /// </summary> /// <param name="oAuth"></param> /// <param name="image">The background image for the profile, base64-encoded. Must be a valid GIF, JPG, or PNG image of less than 800 kilobytes in size.</param> /// <param name="tile">Whether or not to tile the background image. </param> /// <param name="include_entities">The entities node will not be included when set to false.</param> /// <param name="skip_status">When set to either true, t or 1 statuses will not be included in the returned user objects.</param> /// <param name="use">Determines whether to display the profile background image or not</param> /// <returns></returns> public JArray Post_Account_Update_Profile_Background_Image(oAuthTwitter oAuth, string image, string tile, bool include_entities, bool skip_status, bool use) { string RequestUrl = Globals.PostAccountUpdateProfileBackgroungImageUrl; SortedDictionary <string, string> strdic = new SortedDictionary <string, string>(); strdic.Add("include_entities", include_entities.ToString()); strdic.Add("skip_status", skip_status.ToString()); strdic.Add("use", use.ToString()); if (image != null) { strdic.Add("image", image); } if (tile != null) { strdic.Add("tile", tile); } string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, RequestUrl, strdic); if (!response.StartsWith("[")) { response = "[" + response + "]"; } return(JArray.Parse(response)); }
public static bool FollowAccount(oAuthTwitter OAuth, string Screen_name, string user_id) { bool IsFollowed = false; string RequestUrl = "https://api.twitter.com/1.1/friendships/create.json"; SortedDictionary <string, string> strdic = new SortedDictionary <string, string>(); if (!string.IsNullOrEmpty(Screen_name)) { strdic.Add("screen_name", Screen_name); } else if (!string.IsNullOrEmpty(user_id)) { strdic.Add("user_id", user_id); } else { return(false); } strdic.Add("follow", "true"); string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.POST, RequestUrl, strdic); if (!string.IsNullOrEmpty(response)) { IsFollowed = true; } return(IsFollowed); }
/// <summary> /// Sets values that users are able to set under the "Account" tab of their settings page. /// </summary> /// <param name="oAuth"></param> /// <param name="name">Full name associated with the profile. Maximum of 20 characters.</param> /// <param name="url">URL associated with the profile. Will be prepended with "http://" if not present. </param> /// <param name="location">The city or country describing where the user of the account is located.</param> /// <param name="description">A description of the user owning the account. Maximum of 160 characters.</param> /// <param name="include_entities">The entities node will not be included when set to false.</param> /// <param name="skip_status">When set to either true, t or 1 statuses will not be included in the returned user objects.</param> /// <returns></returns> public JArray Post_Account_Update_Profile(oAuthTwitter oAuth, string name, string url, string location, string description, bool include_entities, bool skip_status) { string RequestUrl = Globals.PostAccountUpdateProfileUrl; SortedDictionary <string, string> strdic = new SortedDictionary <string, string>(); strdic.Add("include_entities", include_entities.ToString()); strdic.Add("skip_status", skip_status.ToString()); if (name != null) { strdic.Add("name", name); } if (url != null) { strdic.Add("url", url); } if (location != null) { strdic.Add("location", location); } if (description != null) { strdic.Add("description", description); } string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, RequestUrl, strdic); if (!response.StartsWith("[")) { response = "[" + response + "]"; } return(JArray.Parse(response)); }
/// <summary> /// This method Will Check Rate Limit Of Account Using OAUTH /// </summary> /// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <returns>Return Xml Text With User Details</returns> public XmlDocument Rate_Limit_Status(oAuthTwitter OAuth) { string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, Globals.RateLimitStatusUrl, String.Empty); xmlResult.Load(new StringReader(response)); return(xmlResult); }
private void AuthenticateWithTwitter(string returnUrl) { string url = ""; string xml = ""; var 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.GetLeftPart(UriPartial.Authority) + "/Account/AuthenticatedWithTwitter?state=" + Request["ReturnUrl"]; Response.Redirect(oAuth.AuthorizationLinkGet(), true); } 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); var response = 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); } } }
/// <summary> /// Returns the 20 most recent mentions (tweets containing a users's @screen_name) for the authenticating user. /// </summary> /// <param name="oAuth"></param> /// <returns></returns> public JArray Get_Statuses_Mentions_Timeline(oAuthTwitter oAuth) { SortedDictionary <string, string> strdic = new SortedDictionary <string, string>(); string RequestUrl = Globals.statusesMentionTimelineUrl; string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl, strdic); return(JArray.Parse(response)); }
/// <summary> /// This Method is Depricated. Please Use "Post_Direct_Messages_New(oAuth,text)" instead. /// This will Send DirectMessage to the User /// </summary> /// <param name="User">Twitter UserName Password</param> /// <param name="DirectMessage">DirectMessage</param> /// <param name="UserId">USerId Whom You Want to Send Direct Message</param> /// <returns></returns> public XmlDocument SendDirectMessage(oAuthTwitter OAuth, string DirectMessage, string ScreenName) { string RequestUrl = Globals.NewDirectMessage + "?screen_name=" + ScreenName + "&text="; string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.POST, RequestUrl, OAuth.UrlEncode(DirectMessage));//twtWebReq.PerformWebRequest(User, RequestUrl, "Post", true, ""); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// UnFollow Twitter User Using OAUTH /// </summary> /// <param name="twitterUser">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="UserToFollow">ScreenName Of Whom You Want To UnFollow</param> /// <returns>Returm Xml</returns> public XmlDocument Friendships_Destroy(oAuthTwitter oAuth, int UserId) { string RequestUrl = Socioboard.Twitter.App.Core.Globals.UnFollowUrlById + UserId; string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, RequestUrl, string.Empty); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// This Method Will Show User Statues Using OAUTH /// </summary> /// <param name="oAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="ScreenName">Twitter UserName</param> /// <returns>Return User Status Details</returns> public XmlDocument ShowStatusByScreenName(oAuthTwitter oAuth, string ScreenName) { string RequestUrl = Socioboard.Twitter.App.Core.Globals.ShowStatusUrlByScreenName + ScreenName; string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl, string.Empty); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// This Method is Depricated. Please Use "Get_Direct_Message(oAuth,count)" instead. /// This Method Will Get All Direct Message Of User Using OAUTH /// </summary> /// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="Count">Number Of DirectMessage</param> /// <returns>Xml Text Of DirectMessage</returns> public XmlDocument DirectMessages(oAuthTwitter OAuth, string Count) { string RequestUrl = Socioboard.Twitter.App.Core.Globals.DirectMessageGetByUserUrl + Count; string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl, string.Empty); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// Get All Tweets Sent By User Using OAUTH /// </summary> /// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="Count">Number Of Tweets</param> /// <returns>Return XmlText Of Tweets Sent By User</returns> public XmlDocument Status_UserTimeLine(oAuthTwitter OAuth, string Count, string ScreenName) { string RequestUrl = Globals.UserTimeLineUrl + ScreenName + "&count=" + Count; string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl, string.Empty); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// This Method Get All Followers Details of User /// </summary> /// <param name="oAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="ScreenName">User Screen Name</param> /// <returns></returns> public XmlDocument FollowersStatus(oAuthTwitter oAuth, string ScreenName, string cursor) { string RequestUrl = Globals.FollowerStatusUrl + ScreenName + ".xml?cursor=" + cursor; string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl, string.Empty); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// Follow Twitter User Using OAUTH /// </summary> /// <param name="twitterUser">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="UserToFollow">ScreenName Of Whom You Want To Follow</param> /// <returns>Returm Xml</returns> public XmlDocument Friendships_Create(oAuthTwitter oAuth, string ScreenName, SortedDictionary <string, string> strdic) { string RequestUrl = Socioboard.Twitter.App.Core.Globals.FollowerUrl + ScreenName; string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, RequestUrl, strdic); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// UnFollow Twitter User Using OAUTH /// </summary> /// <param name="twitterUser">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="UserToFollow">ScreenName Of Whom You Want To UnFollow</param> /// <returns>Returm Xml</returns> public XmlDocument Friendships_Destroy(oAuthTwitter oAuth, string ScreenName) { string RequestUrl = Globals.UnFollowUrl + ScreenName; string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, RequestUrl, string.Empty); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// Follow Twitter User Using OAUTH /// </summary> /// <param name="twitterUser">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="UserToFollow">ScreenName Of Whom You Want To Follow</param> /// <returns>Returm Xml</returns> public XmlDocument Friendships_Create(oAuthTwitter oAuth, int UserId) { string RequestUrl = Globals.FollowerUrlById + UserId; string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, RequestUrl, string.Empty); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// Get All ReTweets Sent By User Using OAUTH /// </summary> /// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="Count">Number Of ReTweets</param> /// <returns>Return XmlText Of ReTweets</returns> public XmlDocument Status_RetweetedByMe(oAuthTwitter OAuth, string Count) { string RequestUrl = Socioboard.Twitter.App.Core.Globals.RetweetedByMeUrl + Count; string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl, string.Empty); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// Get All Mentions Of User Using OAUTH,Twitter Api Version 1.0, GlobusTwitterLib Version 1.0.0.0, /// This method is depricated now. /// </summary> /// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="Count">Number Of Tweets</param> /// <returns>Return XmlText Of Mentionc Of User</returns> /// public XmlDocument Status_Mention(oAuthTwitter OAuth, string Count, SortedDictionary <string, string> strdic) { string RequestUrl = Globals.MentionUrl + Count; string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl, strdic); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// Get All ReTweets Sent By User Using OAUTH /// </summary> /// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="Count">Number Of ReTweets</param> /// <returns>Return XmlText Of ReTweets</returns> public XmlDocument Status_Mentions(oAuthTwitter OAuth, string Count) { string RequestUrl = Globals.MentionUrl + Count; string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl, string.Empty); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// This Method Will Update Tweets On Twitter Using OAUTH /// </summary> /// <param name="oAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="StatusText">Status Messages</param> /// <returns>Return Xml Text Of Details</returns> public XmlDocument UpdateStatus(oAuthTwitter oAuth, string StatusText) { string RequestUrl = Globals.UpdateStatusUrl + "?status="; string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, RequestUrl, oAuth.UrlEncode(StatusText)); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// Returns the most recent tweets authored by the authenticating user that have been retweeted by others. /// </summary> /// <param name="oAuth"></param> /// <returns></returns> public JArray Get_Statuses_Retweet_Of_Me(oAuthTwitter oAuth) { string RequestUrl = Globals.statusesRetweetsOfMeUrl; SortedDictionary <string, string> strdic = new SortedDictionary <string, string>(); string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl, strdic); return(JArray.Parse(response)); }
/// <summary> /// This Method Will Get All Friends Id of User /// </summary> /// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="ScreenName">ScreenName Of Whom You Want To Get FriendsId</param> /// <returns>All Friends Id</returns> public XmlDocument FriendsId(oAuthTwitter OAuth, string ScreenName, SortedDictionary <string, string> strdic) { string RequestUrl = Globals.FriendsIdUrl + ScreenName; string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl, strdic); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// This Method is Depricated. Please Use "Post_Direct_Messages_New(oAuth,text)" instead. /// This will Send DirectMessage to the User /// </summary> /// <param name="User">Twitter UserName Password</param> /// <param name="DirectMessage">DirectMessage</param> /// <param name="UserId">USerId Whom You Want to Send Direct Message</param> /// <returns></returns> public XmlDocument SendDirectMessage(oAuthTwitter OAuth, string DirectMessage, int UserId) { string RequestUrl = Socioboard.Twitter.App.Core.Globals.NewDirectMessage + "?user_id=" + UserId + "&text="; string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.POST, RequestUrl, OAuth.UrlEncode(DirectMessage));//twtWebReq.PerformWebRequest(User, RequestUrl, "Post", true, ""); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// This Method Will Get All Followers Id of User /// </summary> /// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="ScreenName">ScreenName Of Whom You Want To Get Followers Id</param> /// <returns>All Followers Id</returns> public XmlDocument FollowersId(oAuthTwitter OAuth, string ScreenName) { string RequestUrl = Globals.FollowersIdUrl + ScreenName; string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl, string.Empty); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// This Method Will Show User Statues By Id Using OAUTH /// </summary> /// <param name="oAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="UserId">Twitter UserId Of User</param> /// <returns>It will Show User Status Details</returns> public XmlDocument ShowStatus(oAuthTwitter oAuth, string UserId) { string RequestUrl = Socioboard.Twitter.App.Core.Globals.ShowStatusUrl + UserId + ".xml"; string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl, string.Empty); xmlResult.Load(new StringReader(response)); return(xmlResult); }
/// <summary> /// This Method Will Get All Trends Of Twitter Using OAUTH /// </summary> /// <param name="User">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <returns>Json Text Of Trends</returns> public XmlDocument SearchMethod(oAuthTwitter OAuth, string SearchKey, string pageindex) { TwitterWebRequest twtWebReq = new TwitterWebRequest(); string RequestUrl = Globals.SearchUrl + SearchKey + "&page=" + pageindex; string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl, string.Empty); xmlResult.Load(new StringReader(response)); return(xmlResult); }