PASS Parameters to an interface and receive the returned Parameters

Source: Internet
Author: User
Send parameters to a URL and receive the returned parameters. Public String sendmsg (string user, string password, string phone, string text) {try {// If (! RegEx. ismatch (phone, @ "^ (13 | 15) \ D {9} $") // return "Incorrect mobile phone number format! "; String url =" http://www.xunsai.net: 8000 /"; string Param = "user =" + User + "& Password =" + password + "& phonenumber =" + phone + "& text =" + TEXT + "& charset = gb2312"; httpwebrequest request = (httpwebrequest) webrequest. create (URL); Request. method = "Post"; request. allowautoredirect = true; request. contenttype = "text/html; charset = gb2312;"; networkcredential NC = new networkcredential (user, password ); Request. credentials = NC; byte [] DATA = encoding. getencoding ("gb2312 "). getbytes (PARAM); Request. contentlength = data. length; stream = request. getrequeststream (); stream. write (data, 0, Data. length); stream. close (); httpwebresponse response = (httpwebresponse) request. getresponse (); streamreader sr = new streamreader (response. getresponsestream (), encoding. getencoding ("gb2312"); string S = Sr. readtoend (); response. close (); Return s;} catch (exception e) {Return e. message ;}} protected void button#click (Object sender, eventargs e) {// put the following strings. empty Replace the string url = string according to the remarks you need. format ("http://bms.hichina.com/sms_gateway/sms_api? "+" User_id = {0} & Password = {1} & mobile_phone = {2} "+" & MSG = {3} & send_date = {4} & subcode = {5 }", string. empty // user ID, String. empty // password, String. empty // phone number, server. urlencode (string. empty) // text message, server. urlencode (string. empty) // sending date, String. empty // enterprise ID); system. net. webClient client = new system. net. webClient (); string reply = client. downloadstring (URL); label1.text = reply ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.