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
- Related articles
- I received a text message asking for a loan, but I didn't actually raise the amount. What happened?
- Desperate and sad, say a short sentence and send it to a circle of friends (42 sentences)
- After notification 1 employment, what should I do if this person replies to a text message saying that he will not report it?
- Besides the normal maintenance of the engine and chassis, what other maintenance should be done?
- Where to pay the fine for traffic violations in Changsha, which bank or traffic police team? Online, etc
- Is the message about refund true? Ask god to tell me.
- Change the mobile phone number, English notification SMS, please help translate. .....
- Ios 14 apple closes the screen and displays the time.
- Why can't I see the number I sent when I received the text message?
- How to change the mobile phone number of Shenyang receiving provident fund SMS?