public void UnFollowUsingProfileID(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string user_id_toUnFollow, out string status) { string currentStatus = string.Empty; try { string unfollowpostdata = "authenticity_token=" + postAuthenticityToken + "&user_id=" + user_id_toUnFollow.Trim();// + user_id_toUnFollow; //string res_PostFollow = globusHttpHelper.postFormData(new Uri("https://twitter.com/i/user/unfollow"), unfollowpostdata, "https://api.twitter.com/receiver.html", string.Empty, "XMLHttpRequest", "true", "https://api.twitter.com"); string res_PostFollow = globusHttpHelper.postFormData(new Uri("https://twitter.com/i/user/unfollow"), unfollowpostdata, "https://twitter.com/following", string.Empty, "XMLHttpRequest", "true", ""); //if (res_PostFollow.EndsWith("new_state\":\"not-following\"}")) if (res_PostFollow.StartsWith("{\"new_state\":\"not-following")||res_PostFollow.EndsWith("new_state\":\"not-following\"}")) { currentStatus = "Unfollowed"; } else if (res_PostFollow.StartsWith("{\"new_state\":\"not-following")) { currentStatus = "Already Unfollowed"; } else { currentStatus = "not Unfollowed"; } status = currentStatus; } catch (Exception ex) { status = "not Unfollowed"; //Log("[ " + DateTime.Now + " ] => [ Method>> UnFollowUsingProfileID --- class>> Unfollower.cs : UnFollow Exception " + ex.Message + " ]"); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Unfollower -- UnFollowUsingProfileID() --> " + ex.Message, Globals.Path_UnfollowerErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> Unfollower -- UnFollowUsingProfileID() --> " + ex.Message, Globals.Path_TwtErrorLogs); } }
public bool UpdateProfile(string profileUsername, string profileLocation, string profileURL, string profileDescription, string localImagePath, string postAuthenticityToken, ref Globussoft.GlobusHttpHelper globusHttpHelper) { string res_ProfilePage = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/settings/profile"), "", ""); string status = ""; if (string.IsNullOrEmpty(profileUsername)) { try { int startIndex = res_ProfilePage.IndexOf("name=\"user[name]\""); string start = res_ProfilePage.Substring(startIndex); int endIndex = start.IndexOf("\">"); string end = start.Substring(0, endIndex); profileUsername = end.Replace("name=\"user[name]\"", "").Replace(" value=\"", ""); } catch (Exception ex) { } } globusHttpHelper.MultiPartImageUpload(profileUsername, profileLocation, profileURL, profileDescription, localImagePath, postAuthenticityToken, ref status); if (status == "okay") { //Log("Profile Updated"); return true; } return false; }
public void Tweet(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string tweetMessage, out string status) { try { //string abc = tweetMessage.Replace("�", " "); //Post Tweet To Account string strpostAuthenticityToken = string.Empty; string get_twitter_first = globusHttpHelper.getHtmlfromUrlIP(new Uri("https://twitter.com/"), IPAddress, IPPort, IPUsername, IPpassword, string.Empty, string.Empty); if (!string.IsNullOrEmpty(get_twitter_first) && !string.IsNullOrWhiteSpace(get_twitter_first)) { strpostAuthenticityToken = PostAuthenticityToken(get_twitter_first, "postAuthenticityToken"); } if (!string.IsNullOrEmpty(tweetMessage) && !string.IsNullOrWhiteSpace(tweetMessage)) { if (tweetMessage.Length > 140) { int index = tweetMessage.Length - 140; tweetMessage = tweetMessage.Remove(tweetMessage.Length - index); string TweetData = "include_entities=true&status=" + HttpUtility.UrlEncode(tweetMessage) + "&post_authenticity_token=" + strpostAuthenticityToken; string res_PostTweet = globusHttpHelper.postFormData(new Uri("https://api.twitter.com/1/statuses/update.json"), TweetData, "https://api.twitter.com/receiver.html", strpostAuthenticityToken, "XMLHttpRequest", "true", ""); status = "posted"; } else { string TweetData = "include_entities=true&status=" + HttpUtility.UrlEncode(tweetMessage) + "&post_authenticity_token=" + strpostAuthenticityToken; string res_PostTweet = globusHttpHelper.postFormData(new Uri("https://api.twitter.com/1/statuses/update.json"), TweetData, "https://api.twitter.com/receiver.html", strpostAuthenticityToken, "XMLHttpRequest", "true", ""); status = "posted"; } } else { status = "Tweet Message Is Empty !"; } } catch (Exception ex) { status = "not posted"; //Log("Method>>Tweet --- class>>Tweeter.cs : Tweet Exception " + ex.Message); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Tweeter() -- Tweet() --> " + ex.Message, Globals.Path_FollowerErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> Tweeter() -- Tweet() --> " + ex.Message, Globals.Path_TwtErrorLogs); } }
public bool LogoutHttpHelper(ref Globussoft.GlobusHttpHelper HttpHelper) { try { string pageSource1 = HttpHelper.getHtmlfromUrl(new Uri("http://www.facebook.com/")); if (pageSource1.Contains("\"h\"") && pageSource1.Contains("post_form_id") && pageSource1.Contains("fb_dtsg")) { string h = string.Empty; string post_form_id = string.Empty; string fb_dtsg = string.Empty; if (pageSource1.Contains("\"h\"")) { string strTemp = pageSource1.Substring(pageSource1.IndexOf("\"h\""), 200); string[] ArrTemp = strTemp.Split('"'); h = ArrTemp[3]; } if (pageSource1.Contains("post_form_id") && pageSource1.Contains("fb_dtsg")) { string strTemp = pageSource1.Substring(pageSource1.IndexOf("post_form_id"), 200); string[] ArrTemp = strTemp.Split('"'); post_form_id = ArrTemp[2]; fb_dtsg = ArrTemp[6]; } string ResponseLogout = HttpHelper.postFormData(new Uri("http://www.facebook.com/logout.php"), "post_form_id=" + post_form_id + "&fb_dtsg=" + fb_dtsg + "&ref=mb&h=" + h); return true; } return false; } catch (Exception ex) { return false; Console.WriteLine(ex.Message); } }
public bool UpdateBackgroundImage(string localImagePath, string postAuthenticityToken, ref Globussoft.GlobusHttpHelper globusHttpHelper) { string res_ProfilePage = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/settings/design"), "", ""); string status = ""; if (!res_ProfilePage.Contains("/account/suspended_help") && !res_ProfilePage.Contains("Suspended Accounts")) { globusHttpHelper.MultiPartImageUploadForBackgroundImage(localImagePath, postAuthenticityToken, ref status); if (status == "okay") { Log("[ " + DateTime.Now + " ] => [ Background Pic Updated ]"); return true; } } else { Log("[ " + DateTime.Now + " ] => [ Account Suspended ]"); return false; } return false; }
public void FollowUsingProfileID(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string user_id_toFollow, out string status) { try { string FollowingData = string.Empty; if (NumberHelper.ValidateNumber(user_id_toFollow)) { FollowingData = "user_id=" + user_id_toFollow + "&post_authenticity_token=" + postAuthenticityToken + ""; } else { FollowingData = "screen_name=" + user_id_toFollow + "&post_authenticity_token=" + postAuthenticityToken + ""; } string res_PostFollow = globusHttpHelper.postFormData(new Uri("https://api.twitter.com/1/friendships/create.json"), FollowingData, "https://api.twitter.com/receiver.html", string.Empty, "XMLHttpRequest", "true", "https://api.twitter.com"); status = "followed"; } catch (Exception ex) { status = "not followed"; Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingProfileID() --> " + ex.Message, Globals.Path_FollowerErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> FollowUsingProfileID() --> " + ex.Message, Globals.Path_TwtErrorLogs); } }
public void FavoriteByUrl(ref Globussoft.GlobusHttpHelper globusHttpHelper, string postAuthenticityToken, string retweetID, out string status) { try { //Post Tweet To Account //authenticity_token=8a67c8aeefc40985cd2ce4cd0ff01a9ae17b5dd2&id=277327596696518656 string ReTweetData = "authenticity_token=" + postAuthenticityToken + "&id=" + retweetID; string ReTweetPostUrl = "https://twitter.com/i/tweet/favorite"; string res_Post_Retweet = globusHttpHelper.postFormData(new Uri(ReTweetPostUrl), ReTweetData, "", postAuthenticityToken, "XMLHttpRequest", "true", ""); if (res_Post_Retweet.Contains("\"stat\":\"favorite\"")) { status = "posted"; } else { status = "not posted"; } } catch (Exception ex) { status = "not posted"; //Log("Method>>ReTweet --- class>>Tweeter.cs : ReTweet Exception " + ex.Message); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Tweeter() - ReTweet --> " + ex.Message, Globals.Path_TweetingErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> Tweeter() - ReTweet --> " + ex.Message, Globals.Path_TwtErrorLogs); } }
public void Reply(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string tweetID, string screenName, string tweetMessage, out string status) { try { //https://twitter.com/i/tweet/create string TweetId = tweetID;//"197551187803906048"; string ReplyData = "authenticity_token=" + postAuthenticityToken + "&in_reply_to_status_id=" + TweetId + "&place_id=&status=%40" + screenName + "+" + Uri.EscapeDataString(tweetMessage); //"in_reply_to_status_id=" + TweetId + "&include_entities=true&status=%40" + "screenname to reply to" + "+" + tweetMessage + "&post_authenticity_token=" + postAuthenticityToken; string res_Post_Reply = globusHttpHelper.postFormData(new Uri("https://twitter.com/i/tweet/create"), ReplyData, "https://twitter.com/" + screenName + "/status/" + tweetID, postAuthenticityToken, "XMLHttpRequest", "true", ""); status = "posted"; ///Reply For twitter api 1.0 //string TweetId = tweetID;// "197682704844734464"; //string ReTweetData = "post_authenticity_token=" + postAuthenticityToken; //string ReTweetPostUrl = "https://api.twitter.com/1/statuses/retweet/" + TweetId + ".json"; //string a6 = globusHttpHelper.postFormData(new Uri(ReTweetPostUrl), ReTweetData, "https://api.twitter.com/receiver.html", postAuthenticityToken, "XMLHttpRequest", "true", ""); //string TweetId = tweetID;//"197551187803906048"; //string ReplyData = "in_reply_to_status_id=" + TweetId + "&include_entities=true&status=%40" + screenName + "+" + HttpUtility.UrlEncode(tweetMessage) + "&post_authenticity_token=" + postAuthenticityToken; ;//"in_reply_to_status_id=" + TweetId + "&include_entities=true&status=%40" + "screenname to reply to" + "+" + tweetMessage + "&post_authenticity_token=" + postAuthenticityToken; //string res_Post_Reply = globusHttpHelper.postFormData(new Uri("https://api.twitter.com/1/statuses/update.json"), ReplyData, "https://api.twitter.com/receiver.html", postAuthenticityToken, "XMLHttpRequest", "true", ""); } catch (Exception ex) { status = "not posted"; //Log("Method>> Reply --- class>> Tweeter.cs : Reply Exception " + ex.Message); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Reply() --> " + ex.Message, Globals.Path_TweetingErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> Reply() --> " + ex.Message, Globals.Path_TwtErrorLogs); } }
public void ReTweetAndFollow(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string tweetID, string tweetMessage, string UserID, out string status) { Follower.Follower objFollower = new Follower.Follower(); try { string TweetId = tweetID;// "197682704844734464"; string ReTweetData = "authenticity_token=" + postAuthenticityToken + "&id=" + tweetID; string ReTweetPostUrl = "https://twitter.com/i/tweet/retweet"; string res_Post_Retweet = globusHttpHelper.postFormData(new Uri(ReTweetPostUrl), ReTweetData, "https://twitter.com/", postAuthenticityToken, "XMLHttpRequest", "true", ""); string pagesource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com"), "", ""); //string TweetId = tweetID;// "197682704844734464"; //string ReTweetData = "post_authenticity_token=" + postAuthenticityToken; //string ReTweetPostUrl = "https://api.twitter.com/1/statuses/retweet/" + TweetId + ".json"; //string res_Post_Retweet = globusHttpHelper.postFormData(new Uri(ReTweetPostUrl), ReTweetData, "https://api.twitter.com/receiver.html", postAuthenticityToken, "XMLHttpRequest", "true", ""); status = "posted"; objFollower.FollowUsingProfileID_New(ref globusHttpHelper, pgSrc, postAuthenticityToken, UserID, out status); } catch (Exception ex) { status = "not posted"; //Log("Method>>ReTweet --- class>>Tweeter.cs : ReTweet Exception " + ex.Message); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Tweeter() - ReTweet --> " + ex.Message, Globals.Path_TweetingErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> Tweeter() - ReTweet --> " + ex.Message, Globals.Path_TwtErrorLogs); } }
//Code added by Lijo For tweeting with images in the wait and reply module public void TweetMessageWithImage(ref Globussoft.GlobusHttpHelper globusHttpHelper, string postAuthenticityToken, string tweetMessage, string ImageFilePath, out string status) { string status1 = string.Empty; bool IsLocalFile = true; string MediaId = string.Empty; ///Read Image Data in Byte ///convert byte in base 64 string try { string _base64String = Convert.ToBase64String(File.ReadAllBytes(ImageFilePath)); try { _base64String = StringEncoderDecoder.EncodeBase64String(_base64String); } catch { } ///call method for posting /// string txid = (UnixTimestampFromDateTime(System.DateTime.Now) * 1000).ToString(); string postData = "authenticity_token=" + postAuthenticityToken + "&iframe_callback=&media=" + _base64String + "&upload_id=" + txid + "&origin=https%3A%2F%2Ftwitter.com"; string response_ = globusHttpHelper.postFormData(new Uri("https://upload.twitter.com/i/media/upload.iframe?origin=https%3A%2F%2Ftwitter.com"), postData, "https://twitter.com/", "", "", "", "https://twitter.com/"); MediaId = globusHttpHelper.getBetween(response_, "snowflake_media_id\":", ",").Replace("snowflake_media_id\":", "").Trim(); string finalpostdata = "authenticity_token=" + postAuthenticityToken + "&media_ids=" + MediaId + "&place_id=&status=" + tweetMessage.Replace(" ", "+") + "&tagged_users="; response_ = globusHttpHelper.postFormData(new Uri("https://twitter.com/i/tweet/create"), finalpostdata, "https://twitter.com/", "", "XMLHttpRequest", "", "https://twitter.com/"); //globusHttpHelper.HttpUploadImageFileWithMessage("https://upload.twitter.com/i/tweet/create_with_media.iframe", ImageFilePath, "media_data[]", "application/octet-stream", nvc, true, ref status1); //if (status1 == "okay") //{ // status1 = "posted"; //} if (response_.Contains("tweet_id")) { status1 = "posted"; } } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetMessageWithImagePostData() -- Tweet -- que_TweetMessages_Hashtags --> " + ex.Message, Globals.Path_TweetingErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetMessageWithImagePostData() -- Tweet -- que_TweetMessages_Hashtags --> " + ex.Message, Globals.Path_TweetAccountManager); } status = status1; }
public void Reply(ref Globussoft.GlobusHttpHelper globusHttpHelper, string postAuthenticityToken, string tweetID, string tweetUserName, string screenName, string tweetMessage, string userName) { try { if (userName == UserName) { string strpostAuthenticityToken = string.Empty; string get_twitter_first = globusHttpHelper.getHtmlfromUrlIP(new Uri("https://twitter.com/"), IPAddress, IPPort, IPUsername, IPpassword, string.Empty, string.Empty); if (!string.IsNullOrEmpty(get_twitter_first) && !string.IsNullOrWhiteSpace(get_twitter_first)) { strpostAuthenticityToken = PostAuthenticityToken(get_twitter_first, "postAuthenticityToken"); } //Reply //string TweetId = tweetID;// "197682704844734464"; //string ReTweetData = "post_authenticity_token=" + postAuthenticityToken; //string ReTweetPostUrl = "https://api.twitter.com/1/statuses/retweet/" + TweetId + ".json"; //string a6 = globusHttpHelper.postFormData(new Uri(ReTweetPostUrl), ReTweetData, "https://api.twitter.com/receiver.html", postAuthenticityToken, "XMLHttpRequest", "true", ""); if (!string.IsNullOrEmpty(tweetMessage) && !string.IsNullOrWhiteSpace(tweetMessage)) { string TweetId = tweetID;//"197551187803906048"; string ReplyData = "in_reply_to_status_id=" + TweetId + "&include_entities=true&status=" + screenName + " " + tweetUserName + " " + HttpUtility.UrlEncode(tweetMessage) + "&post_authenticity_token=" + strpostAuthenticityToken;//"in_reply_to_status_id=" + TweetId + "&include_entities=true&status=%40" + "screenname to reply to" + "+" + tweetMessage + "&post_authenticity_token=" + postAuthenticityToken; string res_Post_Reply = globusHttpHelper.postFormData(new Uri("https://api.twitter.com/1/statuses/update.json"), ReplyData, "https://api.twitter.com/receiver.html", postAuthenticityToken, "XMLHttpRequest", "true", ""); //status = "posted"; Log("[ " + DateTime.Now + " ] => [ Message Posted Sucessfully Where Status Id = " + tweetID + " With User Name : " + userName + " ]"); obj_clsDB_ReplyInterface.DeleteRecordsAfterReplyFromtb_ReplyCampaign(StringEncoderDecoder.Encode(tweetID), StringEncoderDecoder.Encode(userName)); } else { Log("[ " + DateTime.Now + " ] => [ Message Couldn't Post Sucessfully .Since Message Is Empty Where Status Id = " + tweetID + " With User Name : " + userName + " ]"); } } } catch (Exception ex) { //status = "not posted"; Log("[ " + DateTime.Now + " ] => [ Method>> Reply --- class>> Tweeter.cs : Reply Exception With User Name : " + UserName + " " + ex.Message + " ]"); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Reply() --> " + ex.Message, Globals.Path_TweetingErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> Reply() --> " + ex.Message, Globals.Path_TwtErrorLogs); } }
public void FollowUsingProfileID_New(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string user_id_toFollow, out string status) { try { string data_user_id = string.Empty; string PostData = string.Empty; if (NumberHelper.ValidateNumber(user_id_toFollow)) { string tempScreenName = string.Empty; data_user_id = user_id_toFollow; string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/intent/user?user_id=" + user_id_toFollow), "", ""); if (string.IsNullOrEmpty(pageSource)) { pageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/intent/user?user_id=" + user_id_toFollow), "", ""); } tempScreenName = globusHttpHelper.getBetween(pageSource, "<span class=\"name\">", "</span>"); if (!string.IsNullOrEmpty(tempScreenName)) { pageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + tempScreenName), "", ""); } if (!string.IsNullOrEmpty(pageSource)) { try { int startIndx = pageSource.IndexOf("data-user-id=\"") + "data-user-id=\"".Length; int endIndx = pageSource.IndexOf("\"", startIndx); userID = pageSource.Substring(startIndx, endIndx - startIndx); } catch { } if (string.IsNullOrEmpty(userID)) { userID = string.Empty; string[] useridarr = System.Text.RegularExpressions.Regex.Split(pageSource, "data-user-id="); foreach (string useridarr_item in useridarr) { if (useridarr_item.Contains("data-screen-name=")) { userID = useridarr_item.Substring(0 + 1, useridarr_item.IndexOf("data-screen-name=") - 3); break; } } } } } else { try { string data_id = string.Empty; string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + user_id_toFollow), "", ""); if (string.IsNullOrEmpty(pageSource)) { pageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + user_id_toFollow), "", ""); } try { int startIndx = pageSource.IndexOf("data-user-id=\"") + "data-user-id=\"".Length; int endIndx = pageSource.IndexOf("\"", startIndx); userID = pageSource.Substring(startIndx, endIndx - startIndx); } catch { } if (string.IsNullOrEmpty(userID)) { userID = string.Empty; string[] useridarr = System.Text.RegularExpressions.Regex.Split(pageSource, "data-user-id="); foreach (string useridarr_item in useridarr) { if (useridarr_item.Contains("data-screen-name=")) { userID = useridarr_item.Substring(0 + 1, useridarr_item.IndexOf("data-screen-name=") - 3); break; } } } if (globusHttpHelper.gResponse.ResponseUri.ToString().Contains("suspended")) { status = "not followed"; Log(user_id_toFollow + " :- Account is suspended "); return; } string[] data_id1 = System.Text.RegularExpressions.Regex.Split(pageSource, "data-user-id="); if (pageSource.Contains("js-stream-item stream-item stream-item")) { if (pageSource.Contains("profile-card-inner")) { int startindex = pageSource.IndexOf("profile-card-inner"); string start = pageSource.Substring(startindex).Replace("profile-card-inner", ""); int endindex = start.IndexOf("\">"); string end = start.Substring(start.IndexOf("data-user-id="), endindex - start.IndexOf("data-user-id=")).Replace("data-user-id=", "").Replace("\"", ""); data_user_id = end.Trim(); } else { int startindex = pageSource.IndexOf("ProfileTweet-authorDetails\">"); string start = pageSource.Substring(startindex).Replace("ProfileTweet-authorDetails\">", ""); int endindex = start.IndexOf("\">"); string end = start.Substring(start.IndexOf("data-user-id="), endindex - start.IndexOf("data-user-id=")).Replace("data-user-id=", "").Replace("\"", ""); data_user_id = end.Trim(); } } else { try { int startindex = pageSource.IndexOf("profile_id"); string start = pageSource.Substring(startindex).Replace("profile_id", ""); int endindex = start.IndexOf(","); string end = start.Substring(0, endindex).Replace(""", "").Replace("\"", "").Replace(":","").Trim(); data_user_id = end.Trim(); } catch { } if (string.IsNullOrEmpty(data_user_id)) { try { int startindex = pageSource.IndexOf("ProfileTweet-authorDetails\">"); string start = pageSource.Substring(startindex).Replace("ProfileTweet-authorDetails\">", ""); int endindex = start.IndexOf("\">"); string end = start.Substring(start.IndexOf("data-user-id="), endindex - start.IndexOf("data-user-id=")).Replace("data-user-id=", "").Replace("\"", ""); data_user_id = end.Trim(); } catch { } } if (string.IsNullOrEmpty(data_user_id)) { try { int startindex = pageSource.IndexOf("stats js-mini-profile-stats \" data-user-id=\""); if (startindex == -1) { startindex = pageSource.IndexOf("user-actions btn-group not-following not-muting \" data-user-id=\""); } if (startindex == -1) { startindex = pageSource.IndexOf("user-actions btn-group not-following not-muting protected\" data-user-id=\""); } string start = pageSource.Substring(startindex).Replace("stats js-mini-profile-stats \" data-user-id=\"", "").Replace("user-actions btn-group not-following not-muting \" data-user-id=\"", "").Replace("user-actions btn-group not-following not-muting protected\" data-user-id=\"", "").Trim(); //int endindex = start.IndexOf("\">"); int endindex = start.IndexOf("\""); string end = start.Substring(0, endindex); data_user_id = end.Replace("\"", ""); } catch { } } } } catch (Exception err) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingProfileID1()--> " + err.Message, Globals.Path_FollowerErroLog); } } DataSet dt = DataBaseHandler.SelectQuery("SELECT * FROM tb_user_follower_details Where followerId = '" + data_user_id + "' and userId = '" + userID + "' ", "tb_user_follower_details"); int count_NO_RoWs = dt.Tables[0].Rows.Count; if (count_NO_RoWs == 0) { if (!string.IsNullOrEmpty(data_user_id)) { PostData = "authenticity_token=" + postAuthenticityToken + "&user_id=" + data_user_id; string res_PostFollow = globusHttpHelper.postFormData(new Uri("https://twitter.com/i/user/follow"), PostData, "https://twitter.com/" + user_id_toFollow, string.Empty, "XMLHttpRequest", "true", ""); try { if (!string.IsNullOrEmpty(user_id_toFollow) && !string.IsNullOrEmpty(data_user_id)) { // string query = "INSERT INTO tb_UsernameDetails (Username , Userid) VALUES ('" + user_id_toFollow + "' ,'" + data_user_id + "') "; string query = "INSERT INTO tb_user_follower_details (followerName,followerId,userId) VALUES ('" + user_id_toFollow + "' ,'" + data_user_id + "','" + userID + "') "; DataBaseHandler.InsertQuery(query, "tb_UsernameDetails"); } } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingProfileID_New() -->insertingdataintodatabase--> " + ex.Message, Globals.Path_FollowerErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> FollowUsingProfileID_New() -->insertingdataintodatabase--> " + ex.Message, Globals.Path_TwtErrorLogs); } status = "followed"; if (res_PostFollow.Contains("pending")) { status = "pending"; } else if(res_PostFollow.Contains("following")) { status = "followed"; } } else { status = "not followed"; Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingProfileID1()(User ID is null) ", Globals.Path_FollowerErroLog); } } else { status = "Already Followed"; Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingProfileID1()--> DataBase Insert error ", Globals.Path_FollowerErroLog); return; } } catch (Exception ex) { status = "not followed"; //Log("Method>> FollowUsingProfileID --- class>> Follower.cs : Follow Exception " + ex.Message); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingProfileID() --> " + ex.Message, Globals.Path_FollowerErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> FollowUsingProfileID() --> " + ex.Message, Globals.Path_TwtErrorLogs); } }
public void SendDirectMessage(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string user_id_toFollow, string msgBodyCompose, out string status) { try { string data_user_id = string.Empty; string PostData = string.Empty; string Last_message_Id = string.Empty; if (user_id_toFollow.Contains(":")) { data_user_id = user_id_toFollow.Split(':')[0]; } // msgBodyCompose = msgBodyCompose.Replace(" ", "+").Trim(); msgBodyCompose = msgBodyCompose.Trim(); if (!string.IsNullOrEmpty(user_id_toFollow)) { PostData = "authenticity_token=" + postAuthenticityToken + "&lastMsgId=" + Last_message_Id + "&screen_name=" + data_user_id + "&scribeContext%5Bcomponent%5D=dm_existing_conversation_dialog&text=" + Uri.EscapeDataString(msgBodyCompose) + "&tweetboxId="; //PostData = "authenticity_token=" + postAuthenticityToken + "&user_id=" + data_user_id; string res_PostFollow = globusHttpHelper.postFormData(new Uri("https://twitter.com/i/direct_messages/new"), PostData, "https://twitter.com/" + user_id_toFollow, string.Empty, "XMLHttpRequest", "true", ""); try { if (!string.IsNullOrEmpty(user_id_toFollow) && !string.IsNullOrEmpty(data_user_id)) { // string query = "INSERT INTO tb_UsernameDetails (Username , Userid) VALUES ('" + user_id_toFollow + "' ,'" + data_user_id + "') "; //string query = "INSERT INTO tb_user_follower_details (followerName,followerId,userId) VALUES ('" + user_id_toFollow + "' ,'" + data_user_id + "','" + userID + "') "; //DataBaseHandler.InsertQuery(query, "tb_UsernameDetails"); } } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> SendDirectMessage() -->insertingdataintodatabase--> " + ex.Message, Globals.Path_FollowerErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> SendDirectMessage() -->insertingdataintodatabase--> " + ex.Message, Globals.Path_TwtErrorLogs); } status = "Message send"; } else { status = "Message not send"; Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> SendDirectMessage()(User ID is null) ", Globals.Path_FollowerErroLog); } } catch (Exception ex) { status = "Message not send"; //Log("Method>> FollowUsingProfileID --- class>> Follower.cs : Follow Exception " + ex.Message); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> SendDirectMessage() --> " + ex.Message, Globals.Path_FollowerErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> SendDirectMessage() --> " + ex.Message, Globals.Path_TwtErrorLogs); } }
public List<string> GetFollowings_NewForMobileVersion(string userID, out string ReturnStatus, ref Globussoft.GlobusHttpHelper HttpHelper) { Log("[ " + DateTime.Now + " ] => [ Searching For Followers For " + userID + " ]"); string cursor = "0"; int counter = 0; string FollowingUrl = string.Empty; List<string> lstIds = new List<string>(); string Data = string.Empty; string FindCursor = string.Empty; try { StartAgain: //Thread.Sleep(1000); string[] splitRes = new string[] { }; if (counter == 0) { string aa = "https://mobile.twitter.com/" + userID + "/following"; Data = HttpHelper.getHtmlfromUrl(new Uri(aa), "", ""); if (Data.Contains("class=\"w-button-more\"")) { int startindex = Data.IndexOf("cursor="); string start = Data.Substring(startindex).Replace("cursor=", ""); int lastindex = start.IndexOf(">"); if (lastindex < 0) { lastindex = start.IndexOf(">"); } string end = start.Substring(0, lastindex).Replace("\"", ""); cursor = end; } else { //splitRes = Regex.Split(Data, "<div class=\"GridTimeline-items"); } counter++; //Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers"), "", ""); } else { Data = HttpHelper.getHtmlfromUrl(new Uri("https://mobile.twitter.com/" + userID + "/following?cursor=" + cursor), "", ""); if (string.IsNullOrEmpty(Data)) { for (int i = 1; i <= 3; i++) { Thread.Sleep(3000); Data = HttpHelper.getHtmlfromUrl(new Uri("https://mobile.twitter.com/" + userID + "/following?cursor=" + cursor), "", ""); if (!string.IsNullOrEmpty(Data)) { break; } } //if (string.IsNullOrEmpty(Data)) //{ // Log(" pagesource not found "); //} } if (Data == "Too Many Requestes") { Log("[ " + DateTime.Now + " ] => [ Wait for 15 minutes For furthur Scraping because Twitter banned for scraping. its already too many requestes. ]"); Thread.Sleep(15 * 60 * 1000); Data = HttpHelper.getHtmlfromUrl(new Uri("https://mobile.twitter.com/" + userID + "/following?cursor=" + cursor), "", ""); if (string.IsNullOrEmpty(Data) || Data == "Too Many Requestes") { Log("[ " + DateTime.Now + " ] => [ Wait for 5 minutes more For furthur Scraping. ]"); Thread.Sleep(5 * 60 * 1000); for (int i = 1; i <= 3; i++) { Thread.Sleep(3000); Data = HttpHelper.getHtmlfromUrl(new Uri("https://mobile.twitter.com/" + userID + "/following?cursor=" + cursor), "", ""); if (!string.IsNullOrEmpty(Data)) { break; } } //if (string.IsNullOrEmpty(Data)) //{ // Log(" pagesource not found "); //} } } //var avc = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(Data); //cursor = string.Empty; //string DataHtml = (string)avc["items_html"]; //cursor = (string)avc["cursor"]; } if (cursor == "0") { Thread.Sleep(2000); Data = HttpHelper.getHtmlfromUrl(new Uri("https://mobile.twitter.com/" + userID + "/following?cursor=" + cursor), "", ""); } if (Data.Contains("401 Unauthorized")) { ReturnStatus = "Account is Suspended. "; return lstIds; } else if (!Data.Contains("Rate limit exceeded") && !Data.Contains("{\"errors\":[{\"message\":\"Sorry, that page does not exist\",\"code\":34}]}") && !string.IsNullOrEmpty(Data)) { string[] arraydata = null; string startWith = string.Empty; if (Data.Contains("<strong class=\"fullname\">")) { arraydata = Regex.Split(Data, "<strong class=\"fullname\">"); //startWith = ""; } else { //arraydata = Regex.Split(Data, "js-stream-item"); //startWith = "\\\" role=\\\"listitem\\\""; } arraydata = arraydata.Skip(1).ToArray(); foreach (string id in arraydata) { string userid = string.Empty; string username = string.Empty; if (cursor == "0") { try { int startindex = id.IndexOf("id="); string start = id.Substring(startindex).Replace("id=", string.Empty); int endindex = start.IndexOf("&"); string end = start.Substring(0, endindex); userid = end; } catch { } } else { try { int startindex = id.IndexOf("id="); string start = id.Substring(startindex).Replace("id=", string.Empty); int endindex = start.IndexOf("&"); string end = start.Substring(0, endindex); userid = end; } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetFollowers_New() -- " + userid + " --> " + ex.Message, Globals.Path_TwitterDataScrapper); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetFollowers_New() -- " + userid + " --> " + ex.Message, Globals.Path_TwtErrorLogs); } } if (cursor == "0") { try { int startindex = id.IndexOf("@</span>"); string start = id.Substring(startindex).Replace("@</span>", string.Empty); int endindex = start.IndexOf("</span></a>"); string end = start.Substring(0, endindex); username = end; } catch { } } else { try { int startindex = id.IndexOf("@</span>"); string start = id.Substring(startindex).Replace("@</span>", string.Empty); int endindex = start.IndexOf("</span></a>"); string end = start.Substring(0, endindex); username = end; } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetFollowers_New() -- " + username + " --> " + ex.Message, Globals.Path_TwitterDataScrapper); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetFollowers_New() -- " + username + " --> " + ex.Message, Globals.Path_TwtErrorLogs); } } if (CounterDataNo > 0) { if (lstIds.Count == CounterDataNo) { ReturnStatus = "No Error"; lstIds = lstIds.Distinct().ToList(); return lstIds; } else { Globals.lstScrapedUserIDs.Add(userid); lstIds.Add(userid + ":" + username); lstIds = lstIds.Distinct().ToList(); if (username.Contains("/span") || userid.Contains("/span")) { } Log("[ " + DateTime.Now + " ] => [ " + userid + ":" + username + " ]"); //write to csv // GlobusFileHelper.AppendStringToTextfileNewLine(userID + "," + userid + "," + username, Globals.Path_ScrapedFollowingsList); GlobusFileHelper.AppendStringToTextfileNewLine(userID + "," + username, Globals.Path_ScrapedFollowingsList); GlobusFileHelper.AppendStringToTextfileNewLine(username, Globals.Path_ScrapedFollowingsListtxt); } } try { } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetFollowers_New() -- " + username + " --> database --> " + ex.Message, Globals.Path_TwitterDataScrapper); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetFollowers_New() -- " + username + " --> database --> " + ex.Message, Globals.Path_TwtErrorLogs); } } if (Data.Contains("Show more people")) { int startindex = Data.IndexOf("cursor="); string start = Data.Substring(startindex).Replace("cursor=", ""); int lastindex = start.IndexOf(">"); if (lastindex < 0) { lastindex = start.IndexOf(">"); } string end = start.Substring(0, lastindex).Replace("\"", ""); cursor = end; if (cursor != "0") { goto StartAgain; } } ReturnStatus = "No Error"; lstIds = lstIds.Distinct().ToList(); return lstIds; } else if (!Data.Contains("Show more people")) { ReturnStatus = "Sorry, that page does not exist :" + userID; lstIds = lstIds.Distinct().ToList(); return lstIds; } else if (Data.Contains("Rate limit exceeded. Clients may not make more than 150 requests per hour.")) { ReturnStatus = "Rate limit exceeded. Clients may not make more than 150 requests per hour.:-" + userID; lstIds = lstIds.Distinct().ToList(); return lstIds; } else { ReturnStatus = "Error"; lstIds = lstIds.Distinct().ToList(); return lstIds; } } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetFollowers_New() -- " + userID + " --> " + ex.Message, Globals.Path_TwitterDataScrapper); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetFollowers_New() -- " + userID + " --> " + ex.Message, Globals.Path_TwtErrorLogs); ReturnStatus = "Error"; lstIds = lstIds.Distinct().ToList(); return lstIds; } }
public List<string> GetFollowers_New(string userID, out string ReturnStatus, ref Globussoft.GlobusHttpHelper HttpHelper) //GetFollowers_New GetFollowers_New_WithNo_Followers { Dictionary<string, string> checkDuplicate = new Dictionary<string, string>(); Log("[ " + DateTime.Now + " ] => [ Searching For Followers For " + userID + " ]"); string cursor = "0"; int counter = 0; string FollowingUrl = string.Empty; List<string> lstIds = new List<string>(); string Data = string.Empty; string FindCursor = string.Empty; string Data_Min_Postion = ""; int noOfPages = CounterDataNo/18 + 1; ReturnStatus = ""; for (int j = 1; j <= noOfPages; j++) { try { StartAgain: //Thread.Sleep(1000); string[] splitRes = new string[] { }; if (counter == 0) { try { string aa = "https://twitter.com/" + userID + "/followers"; Data = HttpHelper.getHtmlfromUrl(new Uri(aa), "", ""); try { string[] Data_Min_PositionList = Regex.Split(Data, "data-min-position="); Data_Min_Postion = Utils.getBetween(Data_Min_PositionList[1], "\"", "\""); } catch { }; try { if (Data.Contains("<div class=\"stream-container")) { splitRes = Regex.Split(Data, "<div class=\"stream-container"); } else { splitRes = Regex.Split(Data, "<div class=\"GridTimeline-items"); } splitRes = splitRes.Skip(1).ToArray(); if (splitRes[0].Contains("<div class=\"stream profile-stream\">")) { splitRes = Regex.Split(splitRes[0], "<div class=\"stream profile-stream\">"); cursor = splitRes[0].Replace("\"", string.Empty).Replace("\n", string.Empty).Replace(">", string.Empty).Replace("data-cursor=", string.Empty).Trim(); } } catch { }; try { // Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers/users?cursor=" + cursor + "&include_available_features=1&include_entities=1&is_forward=true"), "", ""); // Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers/users?include_available_features=1&include_entities=1&max_position="), "", ""); } catch { }; //Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers"), "", ""); } catch { }; } else { // Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers/users?cursor=" + cursor + "&include_available_features=1&include_entities=1&is_forward=true"), "", ""); Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers/users?include_available_features=1&include_entities=1&max_position=" + Data_Min_Postion), "", ""); if (string.IsNullOrEmpty(Data)) //https://twitter.com/sachin//followers/users?cursor=-1&include_available_features=1&include_entities=1&is_forward=true //https://twitter.com/sachin/followers/users?include_available_features=1&include_entities=1&max_position=1499136517515463071 { for (int i = 1; i <= 3; i++) { Thread.Sleep(3000); // Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers/users?cursor=" + cursor + "&include_available_features=1&include_entities=1&is_forward=true"), "", ""); Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers/users?include_available_features=1&include_entities=1&max_position=" + Data_Min_Postion), "", ""); if (!string.IsNullOrEmpty(Data)) { break; } } } if (Data == "Too Many Requestes") { Log("[ " + DateTime.Now + " ] => [ Wait for 15 minutes For furthur Scraping because Twitter banned for scraping. its already too many requestes. ]"); Thread.Sleep(15 * 60 * 1000); // Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers/users?cursor=" + cursor + "&include_available_features=1&include_entities=1&is_forward=true"), "", ""); Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers/users?include_available_features=1&include_entities=1&max_position=" + Data_Min_Postion), "", ""); if (string.IsNullOrEmpty(Data) || Data == "Too Many Requestes") { Log("[ " + DateTime.Now + " ] => [ Wait for 5 minutes more For furthur Scraping. ]"); Thread.Sleep(5 * 60 * 1000); for (int i = 1; i <= 3; i++) { Thread.Sleep(3000); // Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers/users?cursor=" + cursor + "&include_available_features=1&include_entities=1&is_forward=true"), "", ""); Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers/users?include_available_features=1&include_entities=1&max_position=" + Data_Min_Postion), "", ""); if (!string.IsNullOrEmpty(Data)) { break; } } //if (string.IsNullOrEmpty(Data)) //{ // Log(" pagesource not found "); //} } } } if (Data.Contains("401 Unauthorized")) { ReturnStatus = "Account is Suspended. "; // return lstIds; } else if (!Data.Contains("Rate limit exceeded") && !Data.Contains("{\"errors\":[{\"message\":\"Sorry, that page does not exist\",\"code\":34}]}") && !string.IsNullOrEmpty(Data)) { string[] arraydata = {}; string startWith = string.Empty; try { if (Data.Contains("js-stream-item stream-item stream-item")) { arraydata = Regex.Split(Data, "js-stream-item stream-item stream-item"); startWith = ""; } else { arraydata = Regex.Split(Data, "js-stream-item"); startWith = "\\\" role=\\\"listitem\\\""; } } catch { }; arraydata = arraydata.Skip(1).ToArray(); foreach (string id in arraydata) { if (id.StartsWith(startWith) || id.StartsWith("\" role=\"listitem\"")) { string userid = string.Empty; string username = string.Empty; if (counter == 0) { try { int startindex = id.IndexOf("data-user-id="); string start = id.Substring(startindex).Replace("data-user-id=", string.Empty); int endindex = start.IndexOf("data-feedback-token"); string end = start.Substring(0, endindex).Replace("\"", string.Empty).Trim(); userid = end; } catch { } } else { try { int startindex = id.IndexOf("data-item-id=\\\""); string start = id.Substring(startindex).Replace("data-item-id=\\\"", string.Empty); int endindex = start.IndexOf("\\\""); string end = start.Substring(0, endindex); userid = end; } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetFollowers_New() -- " + userid + " --> " + ex.Message, Globals.Path_TwitterDataScrapper); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetFollowers_New() -- " + userid + " --> " + ex.Message, Globals.Path_TwtErrorLogs); } } if (counter == 0) { try { int startindex = id.IndexOf("data-screen-name="); string start = id.Substring(startindex).Replace("data-screen-name=", string.Empty); int endindex = start.IndexOf("data-user-id="); string end = start.Substring(0, endindex).Replace("\"", string.Empty).Trim(); username = end; } catch { } } else { try { int startindex = id.IndexOf("data-screen-name=\\\""); string start = id.Substring(startindex).Replace("data-screen-name=\\\"", ""); int endindex = start.IndexOf("\\\""); string end = start.Substring(0, endindex); username = end; } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetFollowers_New() -- " + username + " --> " + ex.Message, Globals.Path_TwitterDataScrapper); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetFollowers_New() -- " + username + " --> " + ex.Message, Globals.Path_TwtErrorLogs); } } if (CounterDataNo > 0) { if (lstIds.Count == CounterDataNo) { ReturnStatus = "No Error"; lstIds = lstIds.Distinct().ToList(); return lstIds; } else { Globals.lstScrapedUserIDs.Add(userid); lstIds.Add(userid + ":" + username); lstIds = lstIds.Distinct().ToList(); if (username.Contains("/span") || userid.Contains("/span")) { } Log("[ " + DateTime.Now + " ] => [ " + userid + ":" + username + " ]"); //write to csv try { checkDuplicate.Add(userid, username); GlobusFileHelper.AppendStringToTextfileNewLine(userID + "," + userid + "," + username, Globals.Path_ScrapedFollowersList); GlobusFileHelper.AppendStringToTextfileNewLine(username, Globals.Path_ScrapedFollowersListtxt); //for txt format. } catch(Exception ex) { // return lstIds; } } } try { //if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(userid)) //{ // string query = "INSERT INTO tb_UsernameDetails (Username , Userid) VALUES ('" + username + "' ,'" + userid + "') "; // DataBaseHandler.InsertQuery(query, "tb_UsernameDetails"); //} } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetFollowers_New() -- " + username + " --> database --> " + ex.Message, Globals.Path_TwitterDataScrapper); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetFollowers_New() -- " + username + " --> database --> " + ex.Message, Globals.Path_TwtErrorLogs); } } } if (lstIds.Count == CounterDataNo) { ReturnStatus = "No Error"; lstIds = lstIds.Distinct().ToList(); return lstIds; } else if (Data.Contains("\"has_more_items\":true")) { try { string[] Data_Min_PositionList = Regex.Split(Data, "min_position"); Data_Min_Postion = Utils.getBetween(Data_Min_PositionList[1], ":\"", "\""); } catch { }; lstIds = lstIds.Distinct().ToList(); counter++; continue; } ReturnStatus = "No Error"; lstIds = lstIds.Distinct().ToList(); // return lstIds; } else if (Data.Contains("{\"errors\":[{\"message\":\"Sorry, that page does not exist\",\"code\":34}]}")) { ReturnStatus = "Sorry, that page does not exist :" + userID; lstIds = lstIds.Distinct().ToList(); // return lstIds; } else if (Data.Contains("Rate limit exceeded. Clients may not make more than 150 requests per hour.")) { ReturnStatus = "Rate limit exceeded. Clients may not make more than 150 requests per hour.:-" + userID; lstIds = lstIds.Distinct().ToList(); // return lstIds; } else { ReturnStatus = "Error"; lstIds = lstIds.Distinct().ToList(); // return lstIds; } } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetFollowers_New() -- " + userID + " --> " + ex.Message, Globals.Path_TwitterDataScrapper); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetFollowers_New() -- " + userID + " --> " + ex.Message, Globals.Path_TwtErrorLogs); ReturnStatus = "Error"; lstIds = lstIds.Distinct().ToList(); // return lstIds; } counter++; } lstIds = lstIds.Distinct().ToList(); return lstIds; }
public List<string> GetFollowYourFollowers(string userID, string Screen_name, out string ReturnStatus, Globussoft.GlobusHttpHelper Ghelper) { string cursor = "-1"; string FollowingUrl = string.Empty; List<string> lstIds = new List<string>(); string data_max_position = string.Empty; try { Globussoft.GlobusHttpHelper HttpHelper = new Globussoft.GlobusHttpHelper(); HttpHelper = Ghelper; StartAgain: if (NumberHelper.ValidateNumber(userID)) { string UserPageUrl = string.Empty; if (cursor == "-1") { //UserPageUrl = "https://twitter.com/account/redirect_by_id?id=" + userID; UserPageUrl = "https://twitter.com/" + Screen_name; } else { //UserPageUrl = "https://twitter.com/" + Screen_name + "/followers/users?cursor=" + cursor + "&cursor_index=&cursor_offset=&include_available_features=1&include_entities=1&is_forward=true"; UserPageUrl = "https://twitter.com/" + Screen_name + "/followers/users?include_available_features=1&include_entities=1&max_position=" + data_max_position; } //FollowingUrl = "https://api.twitter.com/1/followers/ids.json?cursor=" + cursor + "&id=" + userID + "";//"https://api.twitter.com/1/friends/ids.json?cursor=-1&screen_name=SocioPro"; string GetUSerPage = HttpHelper.getHtmlfromUrl(new Uri(UserPageUrl), "", ""); FollowingUrl = HttpHelper.gResponse.ResponseUri + "/followers"; } else { //FollowingUrl = "https://twitter.com/" + userID + "/followers"; FollowingUrl = "https://twitter.com/" + Screen_name + "/followers"; } String DataCursor = string.Empty; string Data = HttpHelper.getHtmlfromUrl(new Uri(FollowingUrl), "", ""); String DataCursor1 = string.Empty; if (!Data.Contains("Rate limit exceeded") && !Data.Contains("{\"errors\":[{\"message\":\"Sorry, that page does not exist\",\"code\":34}]}") && !string.IsNullOrEmpty(Data)) { String[] DataDivArr = System.Text.RegularExpressions.Regex.Split(Data, "user-actions btn-group not-following not-muting can-dm "); if (DataDivArr.Count() == 1) { DataDivArr = System.Text.RegularExpressions.Regex.Split(Data, "user-actions btn-group not-following not-muting can-dm "); } foreach (var DataDivArr_item in DataDivArr) { if (DataDivArr_item.Contains("data-cursor")) { String DataCurso = System.Text.RegularExpressions.Regex.Split(Data, "data-cursor")[1]; DataCursor1 = DataCurso.Substring(DataCurso.IndexOf("="), DataCurso.IndexOf(">")).Replace(">", string.Empty).Replace("\n", string.Empty).Replace("\"", string.Empty).Replace("=", string.Empty).Trim(); } //if (DataDivArr_item.Contains("<!DOCTYPE html>") || DataDivArr_item.Contains("cursor")) //{ // continue; //} if (DataDivArr_item.Contains("<!DOCTYPE html>")) { continue; } if (DataDivArr_item.Contains("data-screen-name") && DataDivArr_item.Contains(" data-user-id")) { int endIndex = 0; int startIndex = DataDivArr_item.IndexOf(" data-user-id"); try { endIndex = DataDivArr_item.IndexOf(">"); } catch { } if (endIndex == -1) { endIndex = DataDivArr_item.IndexOf("data-feedback-token"); } if (endIndex == -1) { endIndex = DataDivArr_item.IndexOf(" data-protected=\\\"false"); } try { string GetDataStr = DataDivArr_item.Substring(startIndex, endIndex); string _SCRNameID = (GetDataStr.Substring(GetDataStr.IndexOf("data-user-id"), GetDataStr.IndexOf("data-screen-name", GetDataStr.IndexOf("data-user-id")) - GetDataStr.IndexOf("data-user-id")).Replace("data-user-id", string.Empty).Replace("=", string.Empty).Replace("\"", "").Replace("\\\\n", string.Empty).Replace("data-screen-name=", string.Empty).Replace("\\", "").Trim()); string _SCRName = (GetDataStr.Substring(GetDataStr.IndexOf("data-screen-name="), GetDataStr.IndexOf("data-name", GetDataStr.IndexOf("data-screen-name=")) - GetDataStr.IndexOf("data-screen-name=")).Replace("data-screen-name=", string.Empty).Replace("=", string.Empty).Replace("\"", "").Replace("\\\\n", string.Empty).Replace("data-screen-name=", string.Empty).Replace("\\", "").Trim()); //string _SCRNameID = System.Text.RegularExpressions.Regex.Split(GetDataStr, "data-screen-name")[0].Replace("data-user-id=", string.Empty).Replace("\"", string.Empty).Replace("\\", string.Empty).Replace("n", "").Trim(); //string _SCRName = (GetDataStr.Substring(GetDataStr.IndexOf("data-screen-name"), GetDataStr.IndexOf("data-name=", GetDataStr.IndexOf("data-screen-name")) - GetDataStr.IndexOf("data-screen-name")).Replace("data-screen-name", string.Empty).Replace("\\\"", string.Empty).Replace("\"", string.Empty).Replace(",", "").Replace("=", "").Trim()); if (TweetAccountManager.noOfUnfollows > lstIds.Count) { //lstIds.Add(_SCRName + ":" + _SCRNameID); lstIds.Add(_SCRName); } } catch { } } } if (TweetAccountManager.noOfUnfollows != lstIds.Count) { #region Old Cursor Commented Code //if (Data.Contains("data-cursor")) //{ // int startindex = Data.IndexOf("data-cursor"); // string start = Data.Substring(startindex).Replace("data-cursor", ""); // int lastindex = start.IndexOf("<div class=\"stream profile-stream\">"); // if (lastindex == -1) // { // lastindex = start.IndexOf("\n"); // } // string end = start.Substring(0, lastindex).Replace("\"", "").Replace("\n", string.Empty).Replace("=", string.Empty).Replace(">", string.Empty).Trim(); // cursor = end; // if (cursor != "0") // { // goto StartAgain; // } //} //if (Data.Contains("cursor")) //{ // int startindex = Data.IndexOf("cursor"); // string start = Data.Substring(startindex).Replace("cursor", ""); // int lastindex = start.IndexOf(","); // if (lastindex > 40) // { // lastindex = start.IndexOf("\n"); // } // string end = start.Substring(0, lastindex).Replace("\"", "").Replace("\n", string.Empty).Replace("=", string.Empty).Replace(":", string.Empty).Trim(); // cursor = end; // if (cursor != "0") // { // goto StartAgain; // } //} #endregion data_max_position = Utils.getBetween(Data, "data-max-position=\"", "\""); if (string.IsNullOrEmpty(data_max_position)) { data_max_position = Utils.getBetween(Data, "data-min-position=\"", "\""); } if (!string.IsNullOrEmpty(data_max_position)) { cursor = "1"; goto StartAgain; } } //FollowingUrl = "https://twitter.com/Iloveindia6SihF/followers/users?cursor=" + DataCursor1 + "&cursor_index=&cursor_offset=&include_available_features=1&include_entities=1&is_forward=true"; //FollowingUrl = "https://twitter.com/Fergie/followers/users?cursor=" + DataCursor1 + "&include_available_features=1&include_entities=1&is_forward=true"; ReturnStatus = "No Error"; return lstIds; } else if (Data.Contains("401 Unauthorized")) { ReturnStatus = "Account is Suspended. "; return new List<string>(); } else if (Data.Contains("{\"errors\":[{\"message\":\"Sorry, that page does not exist\",\"code\":34}]}")) { ReturnStatus = "Sorry, that page does not exist :" + userID; return lstIds; } else if (Data.Contains("Rate limit exceeded. Clients may not make more than 150 requests per hour.")) { ReturnStatus = "Rate limit exceeded. Clients may not make more than 150 requests per hour.:-" + userID; return lstIds; } else { ReturnStatus = "Error"; return lstIds; } } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetFollowers1() -- " + userID + " --> " + ex.Message, Globals.Path_TwitterDataScrapper); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetFollowers1() -- " + userID + " --> " + ex.Message, Globals.Path_TwtErrorLogs); ReturnStatus = "Error"; return lstIds; } }
private List<string> GetReplyTime(Globussoft.GlobusHttpHelper globusHttpHelper, string pageSource) { List<string> lstReplyTime = new List<string>(); try { if (pageSource.Contains("tweets-wrapper")) { try { string ReplyUserName = globusHttpHelper.GetDataWithTagValueByTagAndAttributeName(pageSource, "div", "tweets-wrapper"); if (ReplyUserName.Contains("client-and-actions") || ReplyUserName.Contains("_timestamp js-short-timestamp ")) { if (ReplyUserName.Contains("_timestamp js-short-timestamp ")) { List<string> lstTime = globusHttpHelper.GetTextDataByTagAndAttributeName(ReplyUserName, "span", "_timestamp js-short-timestamp "); foreach (string item in lstTime) { try { if (item.Contains("-")) { string[] arrItem = Regex.Split(item, "-"); if (arrItem.Count() > 1) { lstReplyTime.Add(arrItem[1].Trim()); } } else { lstReplyTime.Add(item.Trim()); } } catch { } } } if (ReplyUserName.Contains("client-and-actions")) { List<string> lstTime = globusHttpHelper.GetTextDataByTagAndAttributeName(ReplyUserName, "div", "client-and-actions"); foreach (string item in lstTime) { try { if (item.Contains("-")) { string[] arrItem = Regex.Split(item, "-"); if (arrItem.Count() > 1) { lstReplyTime.Add(arrItem[1].Trim()); } } else { lstReplyTime.Add(item.Trim()); } } catch { } } } } } catch { } } } catch { } return lstReplyTime; }
private List<string> GetTweetTime(Globussoft.GlobusHttpHelper globusHttpHelper, string pageSource) { List<string> lstTweetTime = new List<string>(); try { if (pageSource.Contains("permalink-inner permalink-tweet-container")) { // string[] arrTweetUsername = Regex.Split(pageSource, "permalink-inner permalink-tweet-container"); string TweetUserName = globusHttpHelper.GetDataWithTagValueByTagAndAttributeName(pageSource, "div", "permalink-inner permalink-tweet-container"); if (TweetUserName.Contains("client-and-actions") || TweetUserName.Contains("_timestamp js-short-timestamp ")) { if (TweetUserName.Contains("_timestamp js-short-timestamp ")) { List<string> lstTime = globusHttpHelper.GetTextDataByTagAndAttributeName(TweetUserName, "span", "_timestamp js-short-timestamp "); foreach (string item in lstTime) { try { if (item.Contains("-")) { string[] arrItem = Regex.Split(item, "-"); if (arrItem.Count() > 1) { lstTweetTime.Add(arrItem[1].Trim()); } } else { lstTweetTime.Add(item.Trim()); } } catch { } } } //if (lstTweetTime.Count < 1) { if (TweetUserName.Contains("client-and-actions")) { List<string> lstTime = globusHttpHelper.GetTextDataByTagAndAttributeName(TweetUserName, "div", "client-and-actions"); foreach (string item in lstTime) { try { if (item.Contains("-")) { string[] arrItem = Regex.Split(item, "-"); if (arrItem.Count() > 1) { lstTweetTime.Add(arrItem[1].Trim()); } } else { lstTweetTime.Add(item.Trim()); } } catch { } } } } } } } catch { } return lstTweetTime; }
private List<string> GetStatusIdThroughAjax(ref Globussoft.GlobusHttpHelper globusHttpHelper, string screenName, string MaxId) { string max_id = MaxId; repeatAjaxRequests: try { string status = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/i/profiles/show/" + screenName + "/timeline/with_replies?include_available_features=1&include_entities=1&max_id=" + max_id), "", ""); if (status.Contains(@"/status")) // /status { try { string[] arrStatusId = Regex.Split(status, @"\\\/" + screenName + @"\\\/status\\\/"); foreach (string item in arrStatusId) { try { if (!item.Contains("{\"max_id\":")) { string statusId = string.Empty; string statusIdValue = item.Substring(0, 30); if (statusIdValue.Contains("&")) { try { statusId = statusIdValue.Substring(2, statusIdValue.IndexOf("&")).Replace("&", string.Empty).Trim(); string[] arrCheckStatusId = Regex.Split(statusId, "[^0-9]"); foreach (string item1 in arrCheckStatusId) { try { if (item1.Length > 3) { lstAjaxStatusId.Add(item1); } } catch { } } } catch { } } else { try { statusId = statusIdValue.Substring(2, statusIdValue.IndexOf("\"", 2)).Replace("\"", string.Empty).Trim(); string[] arrCheckStatusId = Regex.Split(statusId, "[^0-9]"); foreach (string item2 in arrCheckStatusId) { try { if (item2.Length > 3) { lstAjaxStatusId.Add(item2); } } catch { } } } catch { } } lstAjaxStatusId = lstAjaxStatusId.Distinct().ToList(); } } catch { } } if (status.Contains("max_id\":")) { try { string max_id1 = status.Substring(status.IndexOf("max_id\":"), status.IndexOf(",", status.IndexOf("max_id\":")) - status.IndexOf("max_id\":")).Replace("max_id\":", string.Empty).Replace("\"", string.Empty).Trim(); string[] arrMaxId = Regex.Split(max_id, "[^0-9]"); foreach (string item in arrMaxId) { try { if (item.Length > 3) { max_id = max_id1; goto repeatAjaxRequests; //List<string> lstNextAjaxId = GetStatusIdThroughAjax(ref globusHttpHelper, screenName, item); //break; } } catch { } } } catch { } } } catch { } } } catch { } lstAjaxStatusId = lstAjaxStatusId.Distinct().ToList(); return lstAjaxStatusId; }
public void ReTweet(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string tweetID, string tweetMessage, out string status) { try { //Post Tweet To Account //ReTweet 0 string strpostAuthenticityToken = string.Empty; string get_twitter_first = globusHttpHelper.getHtmlfromUrlProxy(new Uri("https://twitter.com/"), ProxyAddress, ProxyPort, ProxyUserName, ProxyPassword, string.Empty, string.Empty); if (!string.IsNullOrEmpty(get_twitter_first) && !string.IsNullOrWhiteSpace(get_twitter_first)) { // strpostAuthenticityToken = PostAuthenticityToken(get_twitter_first, "postAuthenticityToken"); } string TweetId = tweetID;// "197682704844734464"; string ReTweetData = "post_authenticity_token=" + postAuthenticityToken; string ReTweetPostUrl = "https://api.twitter.com/1/statuses/retweet/" + TweetId + ".json"; string res_Post_Retweet = globusHttpHelper.postFormData(new Uri(ReTweetPostUrl), ReTweetData, "https://api.twitter.com/receiver.html", postAuthenticityToken, "XMLHttpRequest", "true", ""); status = "posted"; } catch (Exception ex) { status = "not posted"; //Log("Method>>ReTweet --- class>>Tweeter.cs : ReTweet Exception " + ex.Message); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Tweeter() - ReTweet --> " + ex.Message, Globals.Path_TweetingErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> Tweeter() - ReTweet --> " + ex.Message, Globals.Path_TwtErrorLogs); } }
public List<string> GetFollowings_NewForUnfollower(string userID, out string ReturnStatus, ref Globussoft.GlobusHttpHelper HttpHelper) { if (CounterDataNo <= 0) { CounterDataNo = TweetAccountManager.noOfUnfollows; } Log("[ " + DateTime.Now + " ] => [ Searching For Followers For " + userID + " ]"); string cursor = "0"; int counter = 0; string FollowingUrl = string.Empty; List<string> lstIds = new List<string>(); string Data = string.Empty; string FindCursor = string.Empty; int noOfPages = TweetAccountManager.noOfUnfollows / 18 + 1; ReturnStatus = ""; string min_position=string.Empty; try { StartAgain: for (int j = 1; j <= noOfPages; j++) { try { //Thread.Sleep(1000); string[] splitRes = new string[] { }; if (cursor == "0") { string aa = "https://twitter.com/" + userID + "/following"; Data = HttpHelper.getHtmlfromUrl(new Uri(aa), "", ""); try { if (Data.Contains("<div class=\"stream-container")) { splitRes = Regex.Split(Data, "<div class=\"stream-container"); } else { splitRes = Regex.Split(Data, "<div class=\"GridTimeline-items"); } splitRes = splitRes.Skip(1).ToArray(); if (splitRes[0].Contains("<div class=\"stream profile-stream\">")) { splitRes = Regex.Split(splitRes[0], "<div class=\"stream profile-stream\">"); cursor = splitRes[0].Replace("\"", string.Empty).Replace("\n", string.Empty).Replace(">", string.Empty).Replace("data-cursor=", string.Empty).Trim(); } else { cursor = (splitRes[0].Substring(splitRes[0].IndexOf("data-cursor="), splitRes[0].IndexOf(">", splitRes[0].IndexOf("data-cursor=")) - splitRes[0].IndexOf("data-cursor=")).Replace("data-cursor=", string.Empty).Replace("\n", string.Empty).Replace("\"", string.Empty).Replace(",", "").Trim()); } } catch { }; counter++; // cursor = "-1"; // Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/following/users?cursor=" + cursor + "&include_available_features=1&include_entities=1&is_forward=true"), "", ""); //Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers"), "", ""); } else { // Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/following/users?cursor=" + cursor + "&include_available_features=1&include_entities=1&is_forward=true"), "", ""); // Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers/users?include_available_features=1&include_entities=1&max_position=" + min_position),"",""); string followingURL = "https://twitter.com/" + userID + "/following/users?include_available_features=1&include_entities=1&max_position=" + min_position; Data = HttpHelper.getHtmlfromUrl(new Uri(followingURL), "", ""); if (string.IsNullOrEmpty(Data)) { for (int i = 1; i <= 3; i++) { Thread.Sleep(3000); Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers/users?include_available_features=1&include_entities=1&max_position=" + cursor), "", ""); if (!string.IsNullOrEmpty(Data)) { break; } } //if (string.IsNullOrEmpty(Data)) //{ // Log(" pagesource not found "); //} } if (Data == "Too Many Requestes") { Log("[ " + DateTime.Now + " ] => [ Wait for 15 minutes For furthur Scraping because Twitter banned for scraping. its already too many requestes. ]"); Thread.Sleep(15 * 60 * 1000); Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers/users?include_available_features=1&include_entities=1&max_position=" + cursor), "", ""); if (string.IsNullOrEmpty(Data) || Data == "Too Many Requestes") { Log("[ " + DateTime.Now + " ] => [ Wait for 5 minutes more For furthur Scraping. ]"); Thread.Sleep(5 * 60 * 1000); for (int i = 1; i <= 3; i++) { Thread.Sleep(3000); Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/followers/users?include_available_features=1&include_entities=1&max_position=" + cursor), "", ""); if (!string.IsNullOrEmpty(Data)) { break; } } //if (string.IsNullOrEmpty(Data)) //{ // Log(" pagesource not found "); //} } } try { //var avc = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(Data); //cursor = string.Empty; ////string DataHtml = (string)avc["items_html"]; //cursor = (string)avc["cursor"]; } catch { }; } if (cursor == "0") { Thread.Sleep(2000); Data = HttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + userID + "/following"), "", ""); } if (Data.Contains("401 Unauthorized")) { ReturnStatus = "Account is Suspended. "; return lstIds; } else if (!Data.Contains("Rate limit exceeded") && !Data.Contains("{\"errors\":[{\"message\":\"Sorry, that page does not exist\",\"code\":34}]}") && !string.IsNullOrEmpty(Data)) { string[] arraydata = { }; string startWith = string.Empty; try { if (Data.Contains("js-stream-item stream-item stream-item")) { arraydata = Regex.Split(Data, "js-stream-item stream-item stream-item"); startWith = ""; } else { arraydata = Regex.Split(Data, "js-stream-item"); startWith = "\\\" role=\\\"listitem\\\""; } arraydata = arraydata.Skip(1).ToArray(); } catch { }; foreach (string id in arraydata) { if (id.StartsWith(startWith) || id.StartsWith("\" role=\"listitem\"")) { string userid = string.Empty; string username = string.Empty; if (cursor == "0") { try { int startindex = id.IndexOf("data-user-id="); string start = id.Substring(startindex).Replace("data-user-id=", string.Empty); int endindex = start.IndexOf("data-feedback-token"); string end = start.Substring(0, endindex).Replace("\"", string.Empty).Trim(); userid = end; userid = userid.Replace("\\", string.Empty).Trim(); } catch { } } else { try { //int startindex = id.IndexOf("data-item-id=\\\"");//data-item-id=" //string start = id.Substring(startindex).Replace("data-item-id=\\\"", string.Empty); //int endindex = start.IndexOf("\\\""); //string end = start.Substring(0, endindex); //userid = end; try { string[] getUserid = Regex.Split(id, "data-item-id="); try { userid = Utils.getBetween(getUserid[1], "\"", "\""); userid = userid.Replace("\\",string.Empty).Trim(); } catch { }; } catch { }; } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetFollowers_New() -- " + userid + " --> " + ex.Message, Globals.Path_TwitterDataScrapper); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetFollowers_New() -- " + userid + " --> " + ex.Message, Globals.Path_TwtErrorLogs); } } if (cursor == "0") { try { int startindex = id.IndexOf("data-screen-name="); string start = id.Substring(startindex).Replace("data-screen-name=", string.Empty); int endindex = start.IndexOf("data-user-id="); string end = start.Substring(0, endindex).Replace("\"", string.Empty).Trim(); username = end; username = username.Replace("\\",string.Empty).Trim(); } catch { } } else { try { //int startindex = id.IndexOf("data-screen-name=\\\""); //string start = id.Substring(startindex).Replace("data-screen-name=\\\"", ""); //int endindex = start.IndexOf("\\\""); //string end = start.Substring(0, endindex); //username = end; try { string[] getScreenName = Regex.Split(id, "data-screen-name="); try { username = Utils.getBetween(getScreenName[1], "\"", "\""); username = username.Replace("\\", string.Empty).Trim(); } catch { }; } catch { }; } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetFollowers_New() -- " + username + " --> " + ex.Message, Globals.Path_TwitterDataScrapper); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetFollowers_New() -- " + username + " --> " + ex.Message, Globals.Path_TwtErrorLogs); } } if (CounterDataNo > 0) { if (lstIds.Count == CounterDataNo) { ReturnStatus = "No Error"; lstIds = lstIds.Distinct().ToList(); return lstIds; } else { Globals.lstScrapedUserIDs.Add(userid); lstIds.Add(username + ":" + userid); lstIds = lstIds.Distinct().ToList(); if (username.Contains("/span") || userid.Contains("/span")) { } Log("[ " + DateTime.Now + " ] => [ " + userid + ":" + username + " ]"); //write to csv GlobusFileHelper.AppendStringToTextfileNewLine(userID + "," + userid + "," + username, Globals.Path_ScrapedFollowersList); GlobusFileHelper.AppendStringToTextfileNewLine(username, Globals.Path_ScrapedFollowingsListtxt); } } try { //if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(userid)) //{ // string query = "INSERT INTO tb_UsernameDetails (Username , Userid) VALUES ('" + username + "' ,'" + userid + "') "; // DataBaseHandler.InsertQuery(query, "tb_UsernameDetails"); //} } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetFollowers_New() -- " + username + " --> database --> " + ex.Message, Globals.Path_TwitterDataScrapper); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetFollowers_New() -- " + username + " --> database --> " + ex.Message, Globals.Path_TwtErrorLogs); } } } if ((lstIds.Count < CounterDataNo)) { //int startindex = Data.IndexOf("\"cursor\":"); //string start = Data.Substring(startindex).Replace("\"cursor\":", ""); //int lastindex = start.IndexOf("\",\""); //if (lastindex < 0) //{ // lastindex = start.IndexOf("\"}"); //} //string end = start.Substring(0, lastindex).Replace("\"", ""); //cursor = end; if (Data.Contains("data-min-position=") && TweetAccountManager.noOfUnfollows > lstIds.Count) { try { string[] cursorList = Regex.Split(Data, "data-min-position"); //cursor = Utils.getBetween(cursorList[1], "\"", "\""); min_position = Utils.getBetween(cursorList[1], "=\"", "\""); } catch { }; } if (Data.Contains("min_position") && TweetAccountManager.noOfUnfollows > lstIds.Count) { try { string[] cursorList = Regex.Split(Data, "min_position"); //cursor = Utils.getBetween(cursorList[1], ":\"", "\""); min_position = Utils.getBetween(cursorList[1], "=\"", "\""); if (string.IsNullOrEmpty(min_position)) { min_position = Utils.getBetween(cursorList[1],"\":\"","\""); } } catch { }; } if (cursor != "0") { counter++; continue; } } ReturnStatus = "No Error"; lstIds = lstIds.Distinct().ToList(); return lstIds; } else if (Data.Contains("{\"errors\":[{\"message\":\"Sorry, that page does not exist\",\"code\":34}]}")) { ReturnStatus = "Sorry, that page does not exist :" + userID; lstIds = lstIds.Distinct().ToList(); return lstIds; } else if (Data.Contains("Rate limit exceeded. Clients may not make more than 150 requests per hour.")) { ReturnStatus = "Rate limit exceeded. Clients may not make more than 150 requests per hour.:-" + userID; lstIds = lstIds.Distinct().ToList(); return lstIds; } else { ReturnStatus = "Error"; lstIds = lstIds.Distinct().ToList(); return lstIds; } } catch { }; } return lstIds; } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetFollowers_New() -- " + userID + " --> " + ex.Message, Globals.Path_TwitterDataScrapper); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetFollowers_New() -- " + userID + " --> " + ex.Message, Globals.Path_TwtErrorLogs); ReturnStatus = "Error"; lstIds = lstIds.Distinct().ToList(); return lstIds; } }
/// <summary> /// Checks for Email Verification /// Also does Skip /// </summary> public bool CheckVerification(string response, ref Globussoft.GlobusHttpHelper HttpHelper) { //** FB Account Check email varified or not ***********************************************************************************// #region FB Account Check email varified or not string pageSourceCheck = string.Empty; pageSourceCheck = response; string pageSrc1 = string.Empty; string pageSrc2 = string.Empty; string pageSrc3 = string.Empty; string pageSrc4 = string.Empty; string substr1 = string.Empty; #region Commented //if (pageSourceCheck.Contains("Are your friends already on Facebook?") && pageSourceCheck.Contains("Skip this step")) //{ // pageSrc1 = HttpHelper.getHtmlfromUrl(new Uri("http://www.facebook.com/gettingstarted.php?step=classmates_coworkers")); //} //if (pageSrc1.Contains("Fill out your Profile Info") && pageSrc1.Contains("Skip")) //{ // pageSrc2 = HttpHelper.getHtmlfromUrl(new Uri("http://www.facebook.com/gettingstarted.php?step=upload_profile_pic")); //} //if (pageSrc2.Contains("Set your profile picture") && pageSrc2.Contains("Skip")) //{ // pageSrc3 = HttpHelper.getHtmlfromUrl(new Uri("http://www.facebook.com/gettingstarted.php?step=summary")); //} //if (pageSrc3.Contains("complete the sign-up process")) //{ // return false; //} //if (pageSourceCheck.Contains("complete the sign-up process")) //{ // return false; //} #endregion ///Skip Code if ((pageSourceCheck.Contains("Are your friends already on Facebook?") && pageSourceCheck.Contains("Skip this step")) || pageSourceCheck.Contains("window.location.replace(\"http:\\/\\/www.facebook.com\\/gettingstarted.php") || pageSourceCheck.Contains("window.location.replace(\"http:\\/\\/www.facebook.com\\/confirmemail.php")) { pageSrc1 = HttpHelper.getHtmlfromUrl(new Uri("http://www.facebook.com/gettingstarted.php?step=classmates_coworkers")); //} Thread.Sleep(300); //if (pageSrc1.Contains("Fill out your Profile Info") && pageSrc1.Contains("Skip")) //{ pageSrc2 = HttpHelper.getHtmlfromUrl(new Uri("http://www.facebook.com/gettingstarted.php?step=upload_profile_pic")); Thread.Sleep(300); //} //if (pageSrc2.Contains("Set your profile picture") && pageSrc2.Contains("Skip")) //{ pageSrc3 = HttpHelper.getHtmlfromUrl(new Uri("http://www.facebook.com/gettingstarted.php?step=summary")); Thread.Sleep(300); //} ///Check if asks for email //If asks then Set Status as PhoneVerfiedOnly if (pageSrc3.Contains("complete the sign-up process")) { PumpMessage("Account : " + Username + " is NOT Email verified"); InsertUpdateDatabase(AccountStatus.Status(ProfileStatus.PhoneVerfiedOnly)); return false; } else if (pageSourceCheck.Contains("please login to your email account below") || pageSourceCheck.Contains("Go to your email")) { PumpMessage("Account : " + Username + " is NOT Email verified"); InsertUpdateDatabase(AccountStatus.Status(ProfileStatus.PhoneVerfiedOnly)); return false; } } ///Check if asks for email //If asks then Set Status as PhoneVerfiedOnly if (pageSourceCheck.Contains("complete the sign-up process")) { PumpMessage("Account : " + Username + " is NOT Email verified"); InsertUpdateDatabase(AccountStatus.Status(ProfileStatus.PhoneVerfiedOnly)); return false; } else if (pageSourceCheck.Contains("window.location.replace(\"http:\\/\\/www.facebook.com\\/confirmemail.php")) { PumpMessage("Account : " + Username + " is NOT Email verified"); InsertUpdateDatabase(AccountStatus.Status(ProfileStatus.PhoneVerfiedOnly)); return false; } else if (pageSourceCheck.Contains("please login to your email account below") || pageSourceCheck.Contains("Go to your email")) { PumpMessage("Account : " + Username + " is NOT Email verified"); InsertUpdateDatabase(AccountStatus.Status(ProfileStatus.PhoneVerfiedOnly)); return false; } #endregion //** FB Account Check email varified or not ***********************************************************************************// PumpMessage("Account : " + Username + " is Email & Phone verified"); InsertUpdateDatabase(AccountStatus.Status(ProfileStatus.PhonePlusEmailVerified)); return true; }
private void SetRefHttpHelpr(ref Globussoft.GlobusHttpHelper thisHttpHelpr, ref Globussoft.GlobusHttpHelper ForeignhttpHelpr) { thisHttpHelpr = ForeignhttpHelpr; }
public void GetScrapTweetAndReply(ref Globussoft.GlobusHttpHelper globusHttpHelper, ref string userId, ref string userName, ref string Screen_name, ref string postAuthenticityToken) { try { Log("[ " + DateTime.Now + " ] => [ Starting ScrapTweetAndReply.............With User Name : " + UserName + " ]"); string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + Screen_name), "", ""); List<string> lstStatusId = GetstatusId(pageSource, globusHttpHelper, ref Screen_name); if (lstStatusId.Count > 0) { try { int lastIndex = lstStatusId.Count - 1; string max_Id = lstStatusId[lastIndex]; List<string> lstAjaxStatusId = GetStatusIdThroughAjax(ref globusHttpHelper, Screen_name, max_Id); lstStatusId.AddRange(lstAjaxStatusId); lstStatusId = lstStatusId.Distinct().ToList(); } catch { } } Log("[ " + DateTime.Now + " ] => [ Total StatusId = " + lstStatusId.Count + " With User Name : " + UserName + " ]"); int counter = 0; int countDataBeforeSaving = 0; try { DataSet ds = obj_clsDB_ReplyInterface.SelectFromtb_ReplyCampaign(StringEncoderDecoder.Encode(UserName)); countDataBeforeSaving = ds.Tables[0].Rows.Count; } catch { } foreach (string item in lstStatusId) { try { string url = "https://twitter.com/" + Screen_name + "/status/" + item; string pageSourceOfstatusId = globusHttpHelper.getHtmlfromUrl(new Uri(url), "", ""); List<string> lstTweet = GetTweet(globusHttpHelper, pageSourceOfstatusId); List<string> lstTweetUserName = GetTweetUserName(globusHttpHelper, pageSourceOfstatusId); List<string> lstTweetUserId = GetTweetUserId(globusHttpHelper, pageSourceOfstatusId); List<string> lstTweetTime = GetTweetTime(globusHttpHelper, pageSourceOfstatusId); List<string> lstReply = GetReply(globusHttpHelper, pageSourceOfstatusId); List<string> lstReplyUserId = GetReplyUserId(globusHttpHelper, pageSourceOfstatusId); // lstReplyUserId = lstReplyUserId.Distinct().ToList(); List<string> lstReplyUserName = GetReplyUserName(globusHttpHelper, pageSourceOfstatusId); List<string> lstReplyTime = GetReplyTime(globusHttpHelper, pageSourceOfstatusId); int index = 0; foreach (string ReplyUserIditem in lstReplyUserId) { try { #region Variable string statusId = string.Empty; string strPostAuthenticityToken = string.Empty; string UserId = string.Empty; string screenName = string.Empty; string tweet = string.Empty; string tweetUserId = string.Empty; string tweetUserName = string.Empty; string tweetTime = string.Empty; string reply = string.Empty; string replyUserId = string.Empty; string replyUserName = string.Empty; string replyTime = string.Empty; #endregion if (!string.IsNullOrEmpty(ReplyUserIditem) && !string.IsNullOrWhiteSpace(ReplyUserIditem)) { replyUserId = ReplyUserIditem; foreach (string Tweetitem in lstTweet) { try { if (!string.IsNullOrEmpty(Tweetitem) && !string.IsNullOrWhiteSpace(Tweetitem)) { tweet = Tweetitem; break; } } catch { } } foreach (string TweetUserNameitem in lstTweetUserName) { try { if (!string.IsNullOrEmpty(TweetUserNameitem) && !string.IsNullOrWhiteSpace(TweetUserNameitem)) { tweetUserName = TweetUserNameitem; break; } } catch { } } foreach (string TweetUserIditem in lstTweetUserId) { try { if (!string.IsNullOrEmpty(TweetUserIditem) && !string.IsNullOrWhiteSpace(TweetUserIditem)) { tweetUserId = TweetUserIditem; break; } } catch { } } foreach (string lstTweetTimeitem in lstTweetTime) { try { if (!string.IsNullOrEmpty(lstTweetTimeitem) && !string.IsNullOrWhiteSpace(lstTweetTimeitem)) { tweetTime = lstTweetTimeitem; break; } } catch { } } try { reply = lstReply[index]; } catch { } try { replyUserName = lstReplyUserName[index]; } catch { } try { replyTime = lstReplyTime[index]; } catch { } index++; statusId = item; strPostAuthenticityToken = postAuthenticityToken; UserId = userId; UserName = userName; screenName = Screen_Name; if (!string.IsNullOrEmpty(statusId) && !string.IsNullOrWhiteSpace(statusId) && !string.IsNullOrEmpty(UserName) && !string.IsNullOrWhiteSpace(UserName) && !string.IsNullOrEmpty(replyUserId) && !string.IsNullOrWhiteSpace(replyUserId) && !string.IsNullOrEmpty(replyUserName) && !string.IsNullOrWhiteSpace(replyUserName) && !string.IsNullOrEmpty(reply) && !string.IsNullOrWhiteSpace(reply) && !string.IsNullOrEmpty(strPostAuthenticityToken) && !string.IsNullOrWhiteSpace(strPostAuthenticityToken)) //!string.IsNullOrEmpty(UserId) && !string.IsNullOrWhiteSpace(UserId) && { try { DataSet ds = obj_clsDB_ReplyInterface.SelectStatusIdUserNameTweetAndReplyFromtb_ReplyCampaign(StringEncoderDecoder.Encode(statusId), StringEncoderDecoder.Encode(UserName), StringEncoderDecoder.Encode(tweet), StringEncoderDecoder.Encode(reply)); if (ds.Tables[0].Rows.Count < 1) { obj_clsDB_ReplyInterface.InserIntotb_ReplyCampaign(StringEncoderDecoder.Encode(statusId), StringEncoderDecoder.Encode(strPostAuthenticityToken), StringEncoderDecoder.Encode(UserId), StringEncoderDecoder.Encode(userName), StringEncoderDecoder.Encode(screenName), StringEncoderDecoder.Encode(tweetUserId), StringEncoderDecoder.Encode(tweetUserName), StringEncoderDecoder.Encode(replyUserId), StringEncoderDecoder.Encode(replyUserName), StringEncoderDecoder.Encode(tweet), StringEncoderDecoder.Encode(tweetTime), StringEncoderDecoder.Encode(reply), StringEncoderDecoder.Encode(replyTime), StringEncoderDecoder.Encode('0'.ToString())); counter++; Log("[ " + DateTime.Now + " ] => [ " + counter + " Record Saved In Data Base With User Name : " + UserName + " ]"); } } catch { } } } } catch { } } } catch { } } int countDataAfterSaving = 0; try { DataSet ds = obj_clsDB_ReplyInterface.SelectFromtb_ReplyCampaign(StringEncoderDecoder.Encode(UserName)); countDataAfterSaving = ds.Tables[0].Rows.Count; if (countDataBeforeSaving == countDataAfterSaving) { Log("[ " + DateTime.Now + " ] => [ No New Reply With User Name : " + userName + " ] "); } } catch { } Log("[ " + DateTime.Now + " ] => [ PROCESS COMPLTED With User Name : " + userName + " ]"); Log("------------------------------------------------------------------------------------------------------------------------------------------"); } catch { } }
private List<string> GetReply(Globussoft.GlobusHttpHelper globusHttpHelper, string pageSource) { List<string> lstReply = new List<string>(); try { //string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri(url), "", ""); if (pageSource.Contains("tweets-wrapper")) { try { string TweetUserId = globusHttpHelper.GetDataWithTagValueByTagAndAttributeName(pageSource, "div", "tweets-wrapper"); if (TweetUserId.Contains("js-tweet-text")) { List<string> lstTweetReply = globusHttpHelper.GetTextDataByTagAndAttributeName(TweetUserId, "p", "js-tweet-text"); foreach (string item in lstTweetReply) { lstReply.Add(item.Replace("&", string.Empty).Replace("quot;", string.Empty)); } //lstReply.AddRange(lstTweetReply); } } catch { } } } catch { } return lstReply; }
private List<string> GetReplyUserName(Globussoft.GlobusHttpHelper globusHttpHelper, string pageSource) { List<string> lstReplyUserName = new List<string>(); try { //string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri(url), "", ""); if (pageSource.Contains("tweets-wrapper")) { try { string ReplyUserName = globusHttpHelper.GetDataWithTagValueByTagAndAttributeName(pageSource, "div", "tweets-wrapper"); if (ReplyUserName.Contains("username js-action-profile-name")) { try { List<string> lst_ReplyUserName = globusHttpHelper.GetTextDataByTagAndAttributeName(ReplyUserName, "span", "username js-action-profile-name"); foreach (string item in lst_ReplyUserName) { try { if (!string.IsNullOrEmpty(item) && !string.IsNullOrWhiteSpace(item)) { lstReplyUserName.Add(item); } } catch { } } } catch { } } } catch { } } } catch { } lstReplyUserName = lstReplyUserName.Distinct().ToList(); return lstReplyUserName; }
public bool UpdateProfile(string profileUsername, string profileLocation, string profileFirstName, string profileLastName, string profilePic, string profileAbout, string profileGender, ref Globussoft.GlobusHttpHelper globusHttpHelper, string appversion) { string Email = string.Empty; string language = string.Empty; string Username = string.Empty; string gender = string.Empty; string firstname = string.Empty; string lastname = string.Empty; string about = string.Empty; string location = string.Empty; string website = string.Empty; string CsrfMiddleToken = string.Empty; string userid = string.Empty; string Country = string.Empty; //string appversion = string.Empty; string res_ProfilePage = globusHttpHelper.getHtmlfromUrl(new Uri("https://pinterest.com/settings/"), "https://pinterest.com/", "", ""); // string Res_settingPagesource = globusHttpHelper.getHtmlfromUrl(new Uri("https://www.pinterest.com/resource/UserSettingsResource/get/?source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%7D%2C%22context%22%3A%7B%22app_version%22%3A%22da919e8%22%2C%22https_exp%22%3Afalse%7D%2C%22module%22%3A%7B%22name%22%3A%22UserEdit%22%2C%22options%22%3A%7B%22user_id%22%3A%2297460916844499785%22%7D%7D%2C%22append%22%3Afalse%2C%22error_strategy%22%3A0%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EShowModalButton(module%3DUserEdit)&_=1388747100460"), "", ""); Email = getEmail(res_ProfilePage); userid = getUserid(res_ProfilePage); string Res_settingPagesource = globusHttpHelper.getHtmlfromUrl(new Uri("https://www.pinterest.com/resource/UserSettingsResource/get/?source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%7D%2C%22context%22%3A%7B%22app_version%22%3A%22" + appversion + "%22%2C%22https_exp%22%3Afalse%7D%2C%22module%22%3A%7B%22name%22%3A%22UserEdit%22%2C%22options%22%3A%7B%22user_id%22%3A%22" + userid + "%22%7D%7D%2C%22append%22%3Afalse%2C%22error_strategy%22%3A0%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EShowModalButton(module%3DUserEdit)&_=1388747100460"), "", "", ""); CsrfMiddleToken = getCsrfToken(res_ProfilePage); if (string.IsNullOrEmpty(profileFirstName)) { firstname = getFirstName(Res_settingPagesource); } else { firstname = profileFirstName; } if (string.IsNullOrEmpty(profileLastName)) { //lastname = getLastName(res_ProfilePage); lastname = getLastName(Res_settingPagesource); } else { lastname = profileLastName; } if (string.IsNullOrEmpty(profileUsername)) { //Username = getUsername(res_ProfilePage); Username = getUsername(Res_settingPagesource); } else { Username = profileUsername; // CheckUsername: //string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://www.pinterest.com/check_username/?check_username="******"&csrfmiddlewaretoken=" + CsrfMiddleToken), "https://pinterest.com/settings/", "", ""); //if (pageSource.Contains("The username is already in use") || pageSource.Contains("failure")) //{ // Username = RandomStringGenerator.RemoveChars(Username); // if (Username.Count() > 10) // { // Username = Username.Remove(5); //Removes the extra characters // } // string addChars = RandomStringGenerator.RandomNumber(5); // Username = Username + addChars; // if (Username.Count() > 15) // { // Username = Username.Remove(13); //Removes the extra characters // } // goto CheckUsername; //} } gender = profileGender; if (string.IsNullOrEmpty(profileAbout)) { about = getAbout(Res_settingPagesource).Replace(" ", "+"); } else { about = profileAbout; } if (string.IsNullOrEmpty(profileLocation)) { location = getLocation(Res_settingPagesource); } else { location = profileLocation; } website = getWebsite(Res_settingPagesource).Replace(":", "%3A").Replace("/", "%2F").Trim(); //http%3A%2F%2Fwww.somethingfunny.com%2F // string token = getChtoken(res_ProfilePage); string status = ""; bool Updated = false; try { //Change Profile Details .... //string NewPostData = "source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%22first_name%22%3A%22" + firstname + "%22%2C%22last_name%22%3A%22" + lastname + "%22%2C%22username%22%3A%22" + Username + "%22%2C%22about%22%3A%22" + Uri.EscapeUriString(about) + "%22%2C%22location%22%3A%22" + location + "%22%2C%22website_url%22%3A%22" + Uri.EscapeUriString(website) + "%22%7D%2C%22context%22%3A%7B%22app_version%22%3A%22" + appversion + "%22%2C%22https_exp%22%3Afalse%7D%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EShowModalButton(module%3DUserEdit)%23Modal(module%3DUserEdit(resource%3DUserSettingsResource()))"; //string NewPostData = "source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%22first_name%22%3A%22" + firstname + "%22%2C%22last_name%22%3A%22" + lastname + "%22%2C%22username%22%3A%22" + Username + "%22%2C%22about%22%3A%22" + Uri.EscapeUriString(about) + "%22%2C%22location%22%3A%22" + location + "%22%2C%22website_url%22%3A%22" + website + "%22%7D%2C%22context%22%3A%7B%22app_version%22%3A%22" + Uri.EscapeUriString(appversion) + "%22%2C%22https_exp%22%3Afalse%7D%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EShowModalButton(module%3DUserEdit)%23Modal(module%3DUserEdit(resource%3DUserSettingsResource()))"; string NewPostData = "source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%22email%22%3A%22" + Uri.EscapeDataString(Email) + "%22%2C%22locale%22%3A%22en-US%22%2C%22country%22%3A%22BQ%22%2C%22gender%22%3A%22" + gender + "%22%2C%22personalize_from_offsite_browsing%22%3Atrue%2C%22first_name%22%3A%22" + firstname + "%22%2C%22last_name%22%3A%22" + Uri.EscapeDataString(lastname) + "%22%2C%22username%22%3A%22" + Username + "%22%2C%22about%22%3A%22" + about + "%22%2C%22location%22%3A%22"+profileLocation+"%22%2C%22website_url%22%3A%22"+Uri.EscapeDataString(website)+"%22%2C%22email_enabled%22%3Atrue%2C%22email_repins%22%3Atrue%2C%22email_likes%22%3Atrue%2C%22email_follows%22%3Atrue%2C%22email_interval%22%3A%22immediate%22%2C%22email_comments%22%3Atrue%2C%22email_shares%22%3Atrue%2C%22email_friends_joining%22%3Atrue%2C%22email_collaboration_invite%22%3Atrue%2C%22email_product_changes%22%3Atrue%2C%22email_suggestions%22%3Atrue%2C%22email_news%22%3Atrue%2C%22email_updates%22%3Atrue%2C%22email_feedback_and_research%22%3Atrue%2C%22exclude_from_search%22%3Afalse%2C%22login_with_facebook%22%3Afalse%2C%22login_with_twitter%22%3Afalse%2C%22connectToGplus%22%3Afalse%2C%22connectToGoogle%22%3Afalse%2C%22connectToYahoo%22%3Afalse%7D%2C%22context%22%3A%7B%7D%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EButton(class_name%3DsaveSettingsButton%2C+color%3Dprimary%2C+type%3Dsubmit%2C+text%3DSave+Settings)"; // string NewPostData1="source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%22email%22%3A%22"+ Email +"%22%2C%22locale%22%3A%22"+location+"%22%2C%22country%22%3A%22"+Country+"%22%2C%22gender%22%3A%22"+gender+"%22%2C%22personalize_from_offsite_browsing%22%3Atrue%2C%22first_name%22%3A%22"+firstname+"%22%2C%22last_name%22%3A%22"+lastname+"01%22%2C%22username%22%3A%22"+Username+"%22%2C%22about%22%3A%22%22%2C%22location%22%3A%22%22%2C%22"+website+"%22%3A%22%22%2C%22email_enabled%22%3Atrue%2C%22email_repins%22%3Atrue%2C%22email_likes%22%3Atrue%2C%22email_follows%22%3Atrue%2C%22email_interval%22%3A%22immediate%22%2C%22email_comments%22%3Atrue%2C%22email_shares%22%3Atrue%2C%22email_friends_joining%22%3Atrue%2C%22email_collaboration_invite%22%3Atrue%2C%22email_product_changes%22%3Atrue%2C%22email_suggestions%22%3Atrue%2C%22email_news%22%3Atrue%2C%22email_updates%22%3Atrue%2C%22email_feedback_and_research%22%3Atrue%2C%22exclude_from_search%22%3Afalse%2C%22login_with_facebook%22%3Afalse%2C%22login_with_twitter%22%3Afalse%2C%22connectToGplus%22%3Afalse%2C%22connectToGoogle%22%3Afalse%2C%22connectToYahoo%22%3Afalse%7D%2C%22context%22%3A%7B%7D%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EButton(class_name%3DsaveSettingsButton%2C+color%3Dprimary%2C+type%3Dsubmit%2C+text%3DSave+Settings) //string newpostdat = "source_url=/settings/&data={\"options\":{\"email\":\"[email protected]\",\"locale\":\"en-US\",\"country\":\"CO\",\"gender\":\"female\",\"personalize_from_offsite_browsing\":true,\"first_name\":\"kavita012\",\"last_name\":\"Gupta1111\",\"username\":\"kavita1112\",\"about\":\"\",\"location\":\"bhilai\",\"website_url\":\"\",\"email_enabled\":true,\"email_repins\":true,\"email_likes\":true,\"email_follows\":true,\"email_interval\":\"immediate\",\"email_comments\":true,\"email_shares\":true,\"email_friends_joining\":true,\"email_collaboration_invite\":true,\"email_product_changes\":true,\"email_suggestions\":true,\"email_news\":true,\"email_updates\":true,\"email_feedback_and_research\":true,\"exclude_from_search\":false,\"login_with_facebook\":false,\"login_with_twitter\":false,\"connectToGplus\":false,\"connectToGoogle\":false,\"connectToYahoo\":false},\"context\":{}}&module_path=App()>UserSettingsPage(resource=UserSettingsResource())>Button(class_name=saveSettingsButton, color=primary, type=submit, text=Save Settings"; //string NewPostData2 = "source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%22email%22%3A%22kavita1112%40hotmail.com%22%2C%22locale%22%3A%22en-US%22%2C%22country%22%3A%22CO%22%2C%22gender%22%3A%22female%22%2C%22personalize_from_offsite_browsing%22%3Atrue%2C%22first_name%22%3A%22gfgfdg%22%2C%22last_name%22%3A%22gfgfdg%22%2C%22username%22%3A%22kavita11%22%2C%22about%22%3A%22i+am+software+engg%22%2C%22location%22%3A%22bhilai%22%2C%22website_url%22%3A%22%22%2C%22email_enabled%22%3Atrue%2C%22email_repins%22%3Atrue%2C%22email_likes%22%3Atrue%2C%22email_follows%22%3Atrue%2C%22email_interval%22%3A%22immediate%22%2C%22email_comments%22%3Atrue%2C%22email_shares%22%3Atrue%2C%22email_friends_joining%22%3Atrue%2C%22email_collaboration_invite%22%3Atrue%2C%22email_product_changes%22%3Atrue%2C%22email_suggestions%22%3Atrue%2C%22email_news%22%3Atrue%2C%22email_updates%22%3Atrue%2C%22email_feedback_and_research%22%3Atrue%2C%22exclude_from_search%22%3Afalse%2C%22login_with_facebook%22%3Afalse%2C%22login_with_twitter%22%3Afalse%2C%22connectToGplus%22%3Afalse%2C%22connectToGoogle%22%3Afalse%2C%22connectToYahoo%22%3Afalse%7D%2C%22context%22%3A%7B%7D%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EButton(class_name%3DsaveSettingsButton%2C+color%3Dprimary%2C+type%3Dsubmit%2C+text%3DSave+Settings)"; //string pagesource = globusHttpHelper.postFormData(new Uri("https://www.pinterest.com/resource/UserSettingsResource/update/"), NewPostData, "https://www.pinterest.com/settings/"); //pagesource = globusHttpHelper.postFormDataProxy(new Uri("https://www.pinterest.com/resource/UserSettingsResource/update/"), NewPostData, "https://www.pinterest.com/settings/", "", 0, "", ""); string pagesource = globusHttpHelper.postFormData(new Uri("https://www.pinterest.com/resource/UserSettingsResource/update/"), NewPostData, "https://www.pinterest.com/settings/"); //pagesource = globusHttpHelper.postFormDataProxy(new Uri("https://www.pinterest.com/resource/UserSettingsResource/update/"), NewPostData, "https://www.pinterest.com/settings/", "", 0, "", ""); //Change profile Image ..... #region //globusHttpHelper.MultiPartImageUploadPreview(Email, language, firstname, lastname, Username, gender, about, location, website, profilePic, CsrfMiddleToken); //string pagesource = globusHttpHelper.getHtmlfromUrl(new Uri("https://www.pinterest.com/resource/UserSettingsResource/get/?source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%7D%2C%22context%22%3A%7B%22app_version%22%3A%22"+ appversion +"%22%2C%22https_exp%22%3Afalse%7D%2C%22module%22%3A%7B%22name%22%3A%22UserEdit%22%2C%22options%22%3A%7B%22user_id%22%3A%22"+ userid +"%22%7D%7D%2C%22append%22%3Afalse%2C%22error_strategy%22%3A0%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EShowModalButton(module%3DUserEdit)&_=1388476372529") , "" , "" ,""); #endregion if (!String.IsNullOrEmpty(profilePic)) { Updated = globusHttpHelper.MultiPartImageUpload_new(Email, language, firstname, lastname, Username, gender, about, location, website, profilePic, CsrfMiddleToken, appversion); } else { Updated = true; } } catch (Exception) { } if (Updated) { return Updated; } return false; }
private List<string> GetReplyUserId(Globussoft.GlobusHttpHelper globusHttpHelper, string pageSource) { List<string> lstReplyUserId = new List<string>(); try { //string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri(url), "", ""); if (pageSource.Contains("tweets-wrapper")) { try { string ReplyUserId = globusHttpHelper.GetDataWithTagValueByTagAndAttributeName(pageSource, "div", "tweets-wrapper"); if (ReplyUserId.Contains("data-user-id=")) { try { string[] arrDataUserId = Regex.Split(ReplyUserId, "data-user-id="); foreach (string item in arrDataUserId) { try { if (!item.Contains("<div class=\"tweets-wrapper\">") && item.Contains(" ")) { string ReplyUserId1 = item.Substring(0, item.IndexOf(" ")).Replace("\"", string.Empty).Replace(">", string.Empty).Trim(); string[] arrReplyUserId1 = Regex.Split(ReplyUserId1, "[a-zA-Z]"); lstReplyUserId.Add(arrReplyUserId1[0]); } } catch { } } } catch { } } } catch { } } } catch { } //lstReplyUserId=lstReplyUserId.Distinct().ToList(); return lstReplyUserId; }
public List<string> ExtractFriendIDs(ref Globussoft.GlobusHttpHelper HttpHelper, ref string userID) { string pgSrc_HomePage = HttpHelper.getHtmlfromUrl(new Uri("http://www.facebook.com/")); string ProFileURL = string.Empty; string UserId = string.Empty; #region Get User or Account ID if (pgSrc_HomePage.Contains("http://www.facebook.com/profile.php?id=")) { ///Modified Sumit [10-12-2011] #region int startIndx = pgSrc_HomePage.IndexOf("http://www.facebook.com/profile.php?id="); int endIndx = pgSrc_HomePage.IndexOf("\"", startIndx + 1); ProFileURL = pgSrc_HomePage.Substring(startIndx, endIndx - startIndx); if (ProFileURL.Contains("&")) { string[] Arr = ProFileURL.Split('&'); ProFileURL = Arr[0]; } #endregion } if (ProFileURL.Contains("http://www.facebook.com/profile.php?id=")) { UserId = ProFileURL.Replace("http://www.facebook.com/profile.php?id=", ""); if (UserId.Contains("&")) { UserId = UserId.Remove(UserId.IndexOf("&")); } userID = UserId; } #endregion List<string> lstFriend = new List<string>(); string pgSrc_FriendsPage = HttpHelper.getHtmlfromUrl(new Uri("http://www.facebook.com/profile.php?id=" + UserId + "&sk=friends&v=friends")); if (pgSrc_FriendsPage.Contains("http://www.facebook.com/profile.php?id=")) { string[] arr = Regex.Split(pgSrc_FriendsPage, "href"); foreach (string strhref in arr) { if (!strhref.Contains("<!DOCTYPE")) { if (strhref.Contains("profile.php?id")) { int startIndx = strhref.IndexOf("profile.php?id") + "profile.php?id".Length + 1; int endIndx = strhref.IndexOf("\"", startIndx); string profileID = strhref.Substring(startIndx, endIndx - startIndx); if (profileID.Contains("&")) { profileID = profileID.Remove(profileID.IndexOf("&")); } if (profileID.Contains("\\")) { profileID = profileID.Replace("\\", ""); } lstFriend.Add(profileID); } } } } List<string> itemId = lstFriend.Distinct().ToList(); return itemId; }
public void Tweet(ref Globussoft.GlobusHttpHelper globusHttpHelper, string postAuthenticityToken, string tweetMessage, out string status) { string tweetdata = string.Empty; string tweetUrl = string.Empty; string postaTweet = string.Empty; try { //string abc = tweetMessage.Replace("�", " "); //Post Tweet To Account tweetdata = "authenticity_token=" + postAuthenticityToken + "&place_id=&status=" + Uri.EscapeDataString(tweetMessage); tweetUrl = "https://twitter.com/i/tweet/create"; postaTweet = globusHttpHelper.postFormData(new Uri(tweetUrl), tweetdata, "https://twitter.com/", "XMLHttpRequest", "", "", ""); ///Old Twitter 1.0 API code //string TweetData = "include_entities=true&status=" + HttpUtility.UrlEncode(tweetMessage) + "&post_authenticity_token=" + postAuthenticityToken; //string res_PostTweet = globusHttpHelper.postFormData(new Uri("https://api.twitter.com/1/statuses/update.json"), TweetData, "https://api.twitter.com/receiver.html", postAuthenticityToken, "XMLHttpRequest", "true", ""); ///// var message = (Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(postaTweet))["message"]; //string ss=Uri.en if (postaTweet.Contains("Your Tweet was posted!") || message.ToString().Contains("आपका ट्वीट पोस्ट हो गया") || postaTweet.Contains("tweet_id") || message.Contains("tweet_id") || message.ToString().Contains("Your Tweet was posted!") || postaTweet.Contains(message.ToString())) { status = "posted"; } else if (postaTweet.Contains("Your Tweet to") && postaTweet.Contains("has been sent")) { status = "posted"; } else { status = "not posted"; } } catch (Exception ex) { try { if (ex.Message.Contains("Stream was not readable")) { if (!string.IsNullOrEmpty(Globals.DBCUsername) && !string.IsNullOrEmpty(Globals.DBCPassword)) { string _tempCaptcha = globusHttpHelper.getHtmlfromUrl(new Uri("https://www.google.com/recaptcha/api/challenge?k=6LfbTAAAAAAAAE0hk8Vnfd1THHnn9lJuow6fgulO&ajax=1&cachestop=0.88776721409522&lang=en"), "", ""); string captchaChallenge = globusHttpHelper.getBetween(_tempCaptcha, "challenge : '", ",").Replace("challenge : '", "").Replace("'", ""); string ImageUrl = "https://www.google.com/recaptcha/api/image?c=" + captchaChallenge; WebClient webclient = new WebClient(); string captchaText = string.Empty; if (!string.IsNullOrEmpty(captchaChallenge)) { try { //WebIP IPObj = new WebIP("http://192.227.234.242:80"); //IPObj.Credentials = CredentialCache.DefaultCredentials; //webclient.IP = IPObj; byte[] args = webclient.DownloadData(ImageUrl); string[] arr1 = new string[] { Globals.DBCUsername, Globals.DBCPassword, "" }; captchaText = DecodeDBC(arr1, args); } catch { } } if (!string.IsNullOrEmpty(captchaText)) { string mainUrl = "https://twitter.com/account/challenge?challenge=" + captchaChallenge + "&challenge_name=Captcha&response=" + captchaText.Replace(" ", "+"); string response = globusHttpHelper.getHtmlfromUrl(new Uri(mainUrl), "", "", ""); postaTweet = globusHttpHelper.postFormData(new Uri(tweetUrl), tweetdata, "https://twitter.com/", "XMLHttpRequest", "", "", ""); var message = (Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(postaTweet))["message"]; //string ss=Uri.en if (postaTweet.Contains("Your Tweet was posted!") || message.ToString().Contains("आपका ट्वीट पोस्ट हो गया") || postaTweet.Contains("tweet_id") || message.Contains("tweet_id") || message.ToString().Contains("Your Tweet was posted!") || postaTweet.Contains(message.ToString())) { status = "posted"; } else if (postaTweet.Contains("Your Tweet to") && postaTweet.Contains("has been sent")) { status = "posted"; } else { status = "not posted"; } } else { status = "not posted"; } } else { status = "not posted"; } } else { status = "not posted"; Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Tweeter() -- Tweet() --> " + ex.Message, Globals.Path_FollowerErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> Tweeter() -- Tweet() --> " + ex.Message, Globals.Path_TwtErrorLogs); } } catch (Exception exp) { status = "not posted"; Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Tweeter() -- Tweet() --> " + exp.Message, Globals.Path_FollowerErroLog); } } }