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