Java sends text messages using the Feixin Interface

Source: Internet
Author: User

Feixin interface address: http://w.ibtf.net/f.php

Fetion tool class:

Package cpsa3.pack. util; import Java. io. ioexception; import Org. apache. commons. httpclient. header; import Org. apache. commons. httpclient. httpclient; import Org. apache. commons. httpclient. httpexception; import Org. apache. commons. httpclient. namevaluepair; import Org. apache. commons. httpclient. methods. postmethod;/*** api2.1 call: f. PHP? Phone = xxxxxx & Pwd = xxx & to = XXXX & MSG = XXXX & type = 0 * more interface parameters detailed description vip api * 1. phone: Mobile Phone Number * 2.pwd: Feixin password * 3.to: who to send (mobile phone number or flying signal) * 4.msg: Feixin content * 5. type: Operation 0 (blank) send SMS 1 Check friend 2 add friend * 6.u: backup parameter: when the sent content is garbled, add & U = 1 */public class fetion {public static void sendmsg (string _ phone, string _ PWD, string _ to, string _ MSG) at the end) throws httpexception, ioexception {httpclient client = new httpclient (); postmethod post = new postmethod ("http://3.ibt F.sinaapp.com/f.php "); Post. addrequestheader ("Content-Type", "application/X-WWW-form-urlencoded; charset = UTF-8 "); // set transcoding namevaluepair [] DATA = {New namevaluepair ("phone", _ phone), new namevaluepair ("PWD", _ PWD) in the header file ), new namevaluepair ("to", _ to), new namevaluepair ("MSG", _ MSG), new namevaluepair ("type", "0" )};post.setrequestbody(data);client.exe cutemethod (post ); header [] headers = post. getresponseheaders (); In T statuscode = post. getstatuscode (); system. out. println ("statuscode:" + statuscode); For (header H: headers) {system. out. println (H. tostring ();} // string result = new string (post. getresponsebodyasstring (). getbytes ("UTF-8"); // system. out. println (result); system. out. println ("OK! "); Post. releaseconnection ();}}

Test test class:

Package cpsa3.pack. util; import Java. io. ioexception; import Org. apache. commons. httpclient. httpexception; public class test {Private Static string phone = "152 *********"; Private Static string Pwd = "********"; private Static string to = "152 *********"; Private Static string MSG = "Hello: Hello world! "; Public static void main (string [] ARGs) throws httpexception, ioexception {fetion. sendmsg (phone, PWD, to, MSG );}}

PS. Three jar packages need to be imported

Commons-codec-1.4.jar

Commons-httpclient-3.1.jar

Commons-logging-1.1.1.jar

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.