protected string HttpInternalDeleteAllRowsFromTable(string tbl, int port, bool ssl) { string response = String.Empty; try { Chilkat.HttpRequest req = new Chilkat.HttpRequest(); using (Chilkat.Http http = new Chilkat.Http()) { http.UnlockComponent(Constants.cStrChilkatHttpLic); req.UsePost(); req.Path = Constants.cStrHttpDeleteAllRowsInTable; req.AddParam("db", Constants.cStrFlexibleDb); req.AddParam("table", tbl); Chilkat.HttpResponse resp = http.SynchronousRequest(Constants.cStrDomain, port, ssl, req); response = (resp == null) ? http.LastErrorText : resp.BodyStr; } } catch (Exception ex) { response = ex.ToString(); Logging.WriteLog(response); } return(response); }
/// <summary> /// HttpPostCollectionDataDeleteAll() --> Performs an HTPP POST (for a CollectionData delete) request using the Chilkat engine. Returns an HTTP string response. ALL instances of collection data matching 'collectionName' WILL BE DELETED! /// </summary> /// <param name="tName">Indicates the name of the table from the Supplier Portal where the data will be DELETED from</param> /// <param name="collectionName">Indicates the name of the collection for which the request is valid.</param> /// <param name="port">Indicates the port to make the HTTP request</param> /// <param name="ssl">If SSL is used or not (True or False)</param> /// <example><code>s.HttpPostCollectionDataDeleteAll("topimagesystems.com_CLS", "00000323", 80, false);</code></example> protected string HttpPostCollectionDataDeleteAll(string tName, string collectionName, int port, bool ssl) { string response = String.Empty; try { if (tName != String.Empty && collectionName != String.Empty) { Chilkat.HttpRequest req = new Chilkat.HttpRequest(); using (Chilkat.Http http = new Chilkat.Http()) { http.UnlockComponent(Constants.cStrChilkatHttpLic); req.UsePost(); req.Path = Constants.cStrHttpPostCollectionDataDeleteAll; req.AddParam(Constants.cStrHttpPostCollectionDatatName, tName); req.AddParam(Constants.cStrHttpPostCollectionDatacollectionName, Constants.cStrCollectionDataNamePrefix + collectionName); Chilkat.HttpResponse resp = http.SynchronousRequest(Constants.cStrDomain, port, ssl, req); response = (resp == null) ? http.LastErrorText : resp.BodyStr; } } } catch (Exception ex) { response = ex.ToString(); Logging.WriteLog(response); } return(response); }
/// <summary> /// HttpPostCollectionDataTable() --> Performs an HTPP POST for the creation of the CollectionData table using the Chilkat engine. The table name will be the combination of the "customer"_"eFlowAppName". Returns an HTTP string response. /// </summary> /// <param name="customer">Indicates the name of the customer to which the data is bound to</param> /// <param name="eFlowAppName">Indicates the name of the eFlow App to which the data is bound to</param> /// <param name="port">Indicates the port to make the HTTP request</param> /// <param name="ssl">If SSL is used or not (True or False)</param> /// <example><code>s.HttpPostCollectionDataTable("topimagesystems.com", "CLS");</code></example> protected string HttpPostCollectionDataTable(string customer, string eFlowAppName, int port, bool ssl) { string response = String.Empty; try { if (customer != String.Empty && eFlowAppName != String.Empty) { Chilkat.HttpRequest req = new Chilkat.HttpRequest(); using (Chilkat.Http http = new Chilkat.Http()) { http.UnlockComponent(Constants.cStrChilkatHttpLic); req.UsePost(); req.Path = Constants.cStrHttpPostCollectionDataTableUrl; req.AddParam(Constants.cStrHttpPostCollectionDataCustomerParam, customer); req.AddParam(Constants.cStrHttpPostCollectionDataeFlowAppNameParam, eFlowAppName); Chilkat.HttpResponse resp = http.SynchronousRequest(Constants.cStrDomain, port, ssl, req); response = (resp == null) ? http.LastErrorText : resp.BodyStr; } } } catch (Exception ex) { response = ex.ToString(); Logging.WriteLog(response); } return(response); }
public bool LogoutChilkat(ref Chilkat.Http http) { try { string pageSource1 = http.QuickGetStr("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]; } Chilkat.HttpRequest reqLogout = new Chilkat.HttpRequest(); reqLogout.UsePost(); //req.Path = "/login.php?login_attempt=1"; reqLogout.RemoveAllParams(); reqLogout.AddHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16"); //req.SetFromUrl("http://www.facebook.com/login.php?login_attempt=1"); reqLogout.AddParam("post_form_id", post_form_id); reqLogout.AddParam("fb_dtsg", fb_dtsg); reqLogout.AddParam("ref", "mb"); reqLogout.AddParam("h", h); Chilkat.HttpResponse respUsingPostURLEncoded = http.PostUrlEncoded("http://www.facebook.com/logout.php", reqLogout); string ResponseLoginPostURLEncoded = respUsingPostURLEncoded.BodyStr; string pageSource12 = http.QuickGetStr("http://www.facebook.com/"); return true; } return false; } catch (Exception ex) { return false; Console.WriteLine(ex.Message); } }
public string PostData(string URL, string postData, string referer) { string response = string.Empty; ChangeProxy(); //http.SetRequestHeader("Cookie", "PREF=ID=39a7dcb4769a70b5:U=01e856263f78e316:FF=0:TM=1310809062:LM=1311756586:GM=1:S=qiyaqpZc0QJwSHyD;NID=49=Ljnrtc5KZDOFfgRVn1Tt6G6MdaeISmX4vOzE7MSbouPD_4ze6OoSuCMWXlH0Jy7fnAlEYzdYxs4V7JP2DXnKgDxVQMKYY60yWoeCgFIwTL2WWBfmxJZNml5pYdudn5Zw;GAPS=1:tS3_AUBl7WpcKSXAXYMVdDiWuMdX0Q:rAR7mbwZ6PlPnJt-;GALX=7iQKVcsEdN4;GoogleAccountsLocale_session=en_GB;SID=DQAAAIUAAAD1r3xd8mtKrnHFMI4AdB1fuFDSG6YQ98V-_olltRKYgRSHMAgKC9eU88xa6oIay8EgmaV8PRZl1uxi_Q7Hx3etXAUCd42mHJph5YHU015yCzmHUoGdeVpzpFtvPc4xFpnu1Hl2PqXSN4tIlDAY_Qg6vs8I8eoWpiVPPXkLR1WaKcw54W9s1Yx1PxN7C5Nazmc;LSID=blogger|s.IN:DQAAAIYAAACEkfAmZiRHYaawY6Ol0Oguk5C58mprkWFDmf4StK2d_UZDRC6baudw3SoGKkQGBEsB4r2wRrklsK9O1XChX7Pj-UnTPMaDxSz4ADM5O69S-LQhLJx10-1kdeomZSC2NIOWxIpHhoWn1FPrpQrFDgisVLfVsHsjD7l5ASyaLzgzaIxx-XZfuQHaCRgnMRF09vo;[email protected];HSID=AuAY8LSZuG828am_4;SSID=AYAPgLxKQx6efsNxV;APISID=j799BJ0rwj5vK8S3/Aid730sB7T-6RWKbq;SAPISID=BnxZXhygC3cPGeSV/AVHrAqmtZgl16WiOi"); req.RemoveAllParams(); req.UsePost(); //req.Path = "/login.php?login_attempt=1"; req.AddHeader("Accept-Encoding", "gzip,deflate"); req.AddHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); req.AddHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0"); req.AddHeader("Accept", "application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8, */*"); req.AddHeader("Connection", "keep-alive"); //req.AddHeader("Cookie", "PREF=ID=39a7dcb4769a70b5:U=01e856263f78e316:FF=0:TM=1310809062:LM=1311756586:GM=1:S=qiyaqpZc0QJwSHyD;NID=49=Ljnrtc5KZDOFfgRVn1Tt6G6MdaeISmX4vOzE7MSbouPD_4ze6OoSuCMWXlH0Jy7fnAlEYzdYxs4V7JP2DXnKgDxVQMKYY60yWoeCgFIwTL2WWBfmxJZNml5pYdudn5Zw;GAPS=1:tS3_AUBl7WpcKSXAXYMVdDiWuMdX0Q:rAR7mbwZ6PlPnJt-;GALX=7iQKVcsEdN4;GoogleAccountsLocale_session=en_GB;SID=DQAAAIUAAAD1r3xd8mtKrnHFMI4AdB1fuFDSG6YQ98V-_olltRKYgRSHMAgKC9eU88xa6oIay8EgmaV8PRZl1uxi_Q7Hx3etXAUCd42mHJph5YHU015yCzmHUoGdeVpzpFtvPc4xFpnu1Hl2PqXSN4tIlDAY_Qg6vs8I8eoWpiVPPXkLR1WaKcw54W9s1Yx1PxN7C5Nazmc;LSID=blogger|s.IN:DQAAAIYAAACEkfAmZiRHYaawY6Ol0Oguk5C58mprkWFDmf4StK2d_UZDRC6baudw3SoGKkQGBEsB4r2wRrklsK9O1XChX7Pj-UnTPMaDxSz4ADM5O69S-LQhLJx10-1kdeomZSC2NIOWxIpHhoWn1FPrpQrFDgisVLfVsHsjD7l5ASyaLzgzaIxx-XZfuQHaCRgnMRF09vo;[email protected];HSID=AuAY8LSZuG828am_4;SSID=AYAPgLxKQx6efsNxV;APISID=j799BJ0rwj5vK8S3/Aid730sB7T-6RWKbq;SAPISID=BnxZXhygC3cPGeSV/AVHrAqmtZgl16WiOi"); #region PostData string[] arrPostData = Regex.Split(postData, "&"); postDataDictionary.Clear(); foreach (string item in arrPostData) { try { postDataDictionary.Add(item.Split('=')[0], item.Split('=')[1]); } catch (Exception) { } } foreach (var item in postDataDictionary) { req.AddParam(item.Key, item.Value); } #endregion ///Set Referer if (!string.IsNullOrEmpty(referer)) { req.AddHeader("Referer", referer); } Chilkat.HttpResponse respUsingPostURLEncoded = http.PostUrlEncoded(URL, req); string ResponseLoginPostURLEncoded = respUsingPostURLEncoded.BodyStr; response = ResponseLoginPostURLEncoded; return(response); }
public bool LogoutChilkat(ref Chilkat.Http http) { try { string pageSource1 = http.QuickGetStr("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]; } Chilkat.HttpRequest reqLogout = new Chilkat.HttpRequest(); reqLogout.UsePost(); //req.Path = "/login.php?login_attempt=1"; reqLogout.RemoveAllParams(); reqLogout.AddHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16"); //req.SetFromUrl("http://www.facebook.com/login.php?login_attempt=1"); reqLogout.AddParam("post_form_id", post_form_id); reqLogout.AddParam("fb_dtsg", fb_dtsg); reqLogout.AddParam("ref", "mb"); reqLogout.AddParam("h", h); Chilkat.HttpResponse respUsingPostURLEncoded = http.PostUrlEncoded("http://www.facebook.com/logout.php", reqLogout); string ResponseLoginPostURLEncoded = respUsingPostURLEncoded.BodyStr; string pageSource12 = http.QuickGetStr("http://www.facebook.com/"); return(true); } return(false); } catch (Exception ex) { return(false); Console.WriteLine(ex.Message); } }
/// <summary> /// HttpPostCollectionDataQry() --> Performs an HTPP POST (for a CollectionData query) request using the Chilkat engine. /// Returns an HTTP string response. /// Basically gets a collection data from a table. /// </summary> /// <param name="tName">Indicates the name of the table from the Supplier Portal where the data will be read from</param> /// <param name="fn">Indicates the name of the field to query.</param> /// <param name="fv">Indicates the value of the field to query.</param> /// <param name="port">Indicates the port to make the HTTP request</param> /// <param name="ssl">If SSL is used or not (True or False)</param> /// <example><code>s.HttpPostCollectionDataQry("topimagesystems.com_CLS", "cln", "00000002", 80, false);</code></example> protected string HttpPostCollectionDataQry(string tName, string fn, string fv, int port, bool ssl) { string response = String.Empty; try { if (tName != String.Empty && fn != String.Empty && fv != String.Empty) { Chilkat.HttpRequest req = new Chilkat.HttpRequest(); using (Chilkat.Http http = new Chilkat.Http()) { http.UnlockComponent(Constants.cStrChilkatHttpLic); req.UsePost(); req.Path = Constants.cStrHttpPostCollectionDataQuery; req.AddParam(Constants.cStrHttpPostCollectionDatatName, tName); req.AddParam(Constants.cStrHttpPostCollectionDataFn, fn); if (fn == Constants.cStrHttpPostCollectionDatacollectionNameQryCln) { req.AddParam(Constants.cStrHttpPostCollectionDataFv, Constants.cStrCollectionDataNamePrefix + fv); } else { req.AddParam(Constants.cStrHttpPostCollectionDataFv, fv); } Chilkat.HttpResponse resp = null; try { resp = http.SynchronousRequest(Constants.cStrDomain, port, ssl, req); } catch (AccessViolationException exVio) { Logging.WriteLog(exVio.ToString()); } catch (Exception ex) { Logging.WriteLog(ex.ToString()); } Thread.Sleep(50); if (resp == null) { try { resp = http.SynchronousRequest(Constants.cStrDomain, port, ssl, req); } catch (AccessViolationException exVio) { Logging.WriteLog(exVio.ToString()); } catch (Exception ex) { Logging.WriteLog(ex.ToString()); } response = (resp == null) ? http.LastErrorText : resp.BodyStr; } else { response = (resp == null) ? http.LastErrorText : resp.BodyStr; } } } } catch (Exception ex) { response = ex.ToString(); Logging.WriteLog(response); } return(response); }
/// <summary> /// HttpPostInternalCollectionTableQry() --> Performs an HTPP POST (for a CollectionData Table query) request using the Chilkat engine. Returns an HTTP string response. /// Basically gets the table name and table data. /// </summary> /// <param name="tName">Indicates the name of the table from the Supplier Portal where the data will be read from</param> /// <param name="port">Indicates the port to make the HTTP request</param> /// <param name="ssl">If SSL is used or not (True or False)</param> /// <example><code>s.HttpPostInternalCollectionTableQry("topimagesystems.com_CLS", 80, false);</code></example> protected string HttpPostInternalCollectionTableQry(string tName, int port, bool ssl) { string response = String.Empty; try { if (tName != String.Empty) { if (tName != String.Empty) { Chilkat.HttpRequest req = new Chilkat.HttpRequest(); using (Chilkat.Http http = new Chilkat.Http()) { http.UnlockComponent(Constants.cStrChilkatHttpLic); req.UsePost(); req.Path = Constants.cStrHttpPostCollectionDataTableUrl; req.AddParam(Constants.cStrHttpPostCollectionDatatName, tName); Chilkat.HttpResponse resp = null; try { resp = http.SynchronousRequest(Constants.cStrDomain, port, ssl, req); Thread.Sleep(50); } catch (AccessViolationException exVio) { Logging.WriteLog(exVio.ToString()); } catch (Exception ex) { Logging.WriteLog(ex.ToString()); } if (resp == null) { try { resp = http.SynchronousRequest(Constants.cStrDomain, port, ssl, req); } catch (AccessViolationException exVio) { Logging.WriteLog(exVio.ToString()); } catch (Exception ex) { Logging.WriteLog(ex.ToString()); } response = (resp == null) ? http.LastErrorText : resp.BodyStr; } else { response = (resp == null) ? http.LastErrorText : resp.BodyStr; } } } } } catch (Exception ex) { response = ex.ToString(); Logging.WriteLog(response); } return(response); }
private void backworker_DoWork(object sender, DoWorkEventArgs e) { switch (m_process) { case _process.form_loading: { if (m_client != null) { m_phone_count = m_client.PhoneCollection.Count(); } break; } case _process.send_sms: { int demo_count = datam.GetSmsDemoCount(); if (demo_count >= DEMO_MAX) { MessageBox.Show("Your SMS Demo Version Has Expired"); return; } else { //if (m_phone_count > demo_count) //{ // if (m_phone_count > DEMO_MAX) // { // m_phone_count = DEMO_MAX - demo_count; // } // else // { // m_phone_count = m_phone_count - demo_count; // } // MessageBox.Show(string.Format("Your SMS Demo Version Has Almost Over,Only {0} SMS Will Be Sent", m_phone_count)); // m_PhoneCollection = m_PhoneCollection.Take(m_phone_count); //} // m_phone_count = 2; } m_phone_count = 2; #region Webservice Settings // Chilkat.HttpRequest req = new Chilkat.HttpRequest(); Chilkat.Http http = new Chilkat.Http(); bool success; //Any string unlocks the component for the 1st 30-days. success = http.UnlockComponent("30277129240"); if (success != true) { MessageBox.Show("Invalid Use Of The Chilkat Library"); return; } // Build an HTTP POST Request: req.UsePost(); req.Path = "/api.php"; req.AddParam("username", "*****@*****.**"); req.AddParam("password", "prpc2qb7"); req.AddParam("from", m_HEADER); req.AddParam("message", m_MESSAGE); // req.AddParam("recipients", "256772332619,256772508360"); req.AddParam("recipients", "256701871684"); m_PhoneString = GetPhoneString(); // req.AddParam("recipients", m_PhoneString); #region compression //MessageBox.Show(m_PhoneString.Length.ToStringNullable(); //Chilkat.Gzip gzip = new Chilkat.Gzip(); //// Any string unlocks the component for the 1st 30-days. //success = gzip.UnlockComponent("ZIP12345678_4F507D55AD1G"); //if (success != true) //{ // MessageBox.Show(gzip.LastErrorText); // return; //} //string cs; //cs = gzip.DeflateStringENC(m_PhoneString, "windows-1252", "base64"); //MessageBox.Show(cs.Length.ToStringNullable(); //return; #endregion //req.AddParam("recipients", m_PhoneString); req.AddParam("type", "normal"); req.AddParam("token", "c4ca4238a0b923820dcc509a6f75849b"); // Send the HTTP POST and get the response. Note: This is a blocking call. // The method does not return until the full HTTP response is received. string domain; int port; bool ssl; domain = "http://208.111.47.244"; port = 80; ssl = false; Chilkat.HttpResponse resp = null; resp = http.SynchronousRequest(domain, port, ssl, req); if (resp == null) { // MessageBox.Show(http.LastErrorText); MessageBox.Show("There Seems To Be A Problem With Your Internet Connection ,SMS Has Not Been Sent", "SMS Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var _res = resp.BodyStr.Trim(); string error_str = null; if (!string.IsNullOrEmpty(_res)) { int _ret = -1; if (_res.Split(new char[] { ':' }).Length > 1) { _res = _res.Split(new char[] { ':' })[0]; } int.TryParse(_res, out _ret); if (_ret >= 0) { switch ((_sms_status)_ret) { case _sms_status.success: { m_status = _sms_status.success; break; } case _sms_status.insufficientcredit: { error_str = "You Do Not Have Sufficient Credit On Your Account,Please Contact Smart IT Solutions"; m_status = _sms_status.insufficientcredit; break; } case _sms_status.invalid_request: { error_str = "The Http Request You Made Is Not Valid"; m_status = _sms_status.invalid_request; break; } case _sms_status.invalid_user: { m_status = _sms_status.invalid_user; error_str = "Invalid UserName Or Password"; break; } default: { error_str = "Unknown Error,Please Contact Smart IT Solutions"; m_status = _sms_status.unknown; break; } } } } if (!string.IsNullOrEmpty(error_str)) { dbm.ErrorMessage(error_str, "SMS Send ERROR"); } } http.Dispose(); #endregion break; } case _process.test_mode: { m_status = _sms_status.success; break; } } }