Joke Collection Website - Public benefit messages - Test the short message interface applet written by java.

Test the short message interface applet written by java.

/**

*? Deal? Post? Request.

*/

Parcel? com . DC . util;

Import? Java . util . map;

Import? Java . util . iterator;

Import? org . Apache . commons . mons . mons . mons . mons . http client . http exception;

Public? Class? PostRequest? Artifacts? java.io.Serializable? {

Private? Map? Parameter;

Private? String? Website;

Public? PostRequest()? {

}

Public? Invalid? SetParameters (map? param)? {

What if? (param? ! =? Empty)

Parameters? =? param

}

Public? Map? getParameters()? {

Return? Parameter;

}

Public? Invalid? SetUrl (string? Website)? {

What if? (Website? ! =? null? & amp& amp? ! (url.equals(" "))

this.url? =? Website;

}

Public? String? getUrl()? {

Return? Website;

}

Public? String? getPost()? Throwing? java.io.IOException,? HttpException? {

What if? (Website? ==? null? ||? url.equals(" ")? ||? Parameters? ==? Empty)

Throw? New? IllegalStateException(

"Invalid? Website? Or? Parameters? Are you online? PostBean.getPost? Method. " );

String? returnData? =? "";

HttpClient? httpClient? =? New? http client();

Ex post facto method? Ex post facto method? =? New? post method(URL);

NameValuePair[]? postData? =? GetParams (parameter);

postMethod.getParams()。 setContentCharset(" GBK "); ?

post method . add parameters(post data);

http client . execute method(post method);

What if? (postMethod.getStatusCode()? ==? HttpStatus。 SC_OK)? {

returnData? =? postmethod . getresponsebodyasstring();

}? Or what? {

returnData? =? "Error:?" ? +? post method . getstatusline();

}

post method . release connection();

Return? returnData

}

Private? NameValuePair[]? GetParams (map? Map)? {

NameValuePair[]? Pairs? =? New? name value pair[map . size()];

Iterator? iter? =? map.keySet()。 Iterator ();

int? Me? =? 0;

What time? (iter.hasNext())? {

String? Keys? =? (string)? ITER . next();

pairs[i]? =? New? NameValuePair (key, (string)? map . get(key));

i++;

}

Return? Pairs;

}

} implementation method:

? Public? Class? DCSMSender{

PostRequest? Public relations? =? New? post request();

Public? Static electricity String? smsUrl? =? DomainGlobal。 SMS _ URL

Private? Static electricity DCSMSender? Examples? =? New? DCSMSender();

Public? Static electricity DCSMSender? getInstance()? {

Return? Examples;

}

Private? DCSMSender()? {

}

/**

*? Send the specified information to the specified mobile phone number (s).

*?

*? @param? Cell phone? mobile phone number

*? @param? Msg message content

*? @ returned successfully, failed.

*/

Public? Bull? send(String[]? Cell phone? String? MSG)? {

Map? param? =? New? HashMap();

String? The result? =? "";

Param.put ("mobile phone", java.util.Arrays.toString);

Param.put("msg ",DcipherTrans.cipher("system", monosodium glutamate,? True));

pr . set parameters(param);

pr . seturl(smsUrl);

Try it? {

The result? =? pr . get post();

What if? ("1". Equal to (result))? Return? True;

Or what? Return? Fake;

}? Catch? (exception? e)? {

e . printstacktrace();

Return? Fake;

}

}

}

This is the method of sending short messages used in my project.

Hope to adopt