璇存槑锛孞AVA鍙戦€佹墜鏈虹煭淇?娴佷紶鏈夊嚑绉嶆柟娉?(1)浣跨敤webservice鎺ュ彛鍙戦€佹墜鏈虹煭淇?杩欎釜鍙互浣跨敤sina鎻愪緵鐨剋ebservice杩涜鍙戦€?浣嗘槸闇€瑕佽繘琛屾敞鍐?(2)浣跨敤鐭俊mao鐨勬柟寮忚繘琛岀煭淇$殑鍙戦€?杩欑鏂瑰紡搴旇鏄瘮杈冪殑甯哥敤,鍓嶆彁鏄渶瑕佽喘涔扮‖浠惰澶? (3)浣跨敤涓浗缃戝缓鎻愪緵鐨凷MS鐭俊骞冲彴.
杩欓噷浣跨敤涓浗缃戝缓鎻愪緵鐨凙PI缁欐墜鏈哄彂閫佺煭淇°€備负浜嗕娇鐢ㄤ腑鍥界綉寤虹粰瀵规柟鎵嬫満鍙戦€佺煭淇★紝闇€瑕佷互涓嬪嚑姝ユ搷浣滐細
1.鐧诲綍涓浗缃戝缓锛屽湴鍧€涓猴細http://sms.webchinese.cn/
2.娉ㄥ唽锛屾敞鍐屽悗浣犲氨浼氭湁鐢ㄦ埛鍚嶅拰瀵嗙爜锛屽瘑鐮佷細鑷姩鍙戝埌浣犵殑鎵嬫満閲?
3.鑾峰彇缃戠鎺ュ彛瀵嗙爜锛岃嚦浜庡浣曡幏寰楃綉鍏虫帴鍙e瘑鐮侊紝鎴戞槸杩欐牱鍋跺皵鑾峰緱鐨勶紙娉ㄦ剰锛岃繖閲岀殑缃戠鎺ュ彛瀵嗙爜骞朵笉鏄綘娉ㄥ唽鏃跺彂閫佸埌浣犳墜鏈洪噷鐨勫瘑鐮侊紝閭e瘑鐮佹槸鐧诲綍瀵嗙爜锛夈€傚湪璇ョ綉绔欓噷灏濊瘯鍙戜竴鏉$煭淇★紝鍙戠煭淇℃椂浼氭湁鐩稿簲鐨勬彁绀猴紝鍦ㄥ彂閫佺殑杩囩▼涓細鍑虹幇浣犵殑缃戝叧鎺ュ彛瀵嗙爜銆?
娉ㄦ剰锛氫綘瑕佷繚瀛樺ソ浣犵殑缃戝叧鎺ュ彛绉樺瘑锛屽洜涓烘瘡娆″綋浣犱娇鐢ㄤ唬鐮佸彂閫佷俊鎭椂閮介渶瑕佽繖涓綉鍏虫帴鍙e瘑鐮併€?
浠ヤ笅浠g爜鎵€浣跨敤鐨刯ar鍙互浠巋ttp://sms.webchinese.cn/鐩存帴鑾峰緱銆?
import java.io.UnsupportedEncodingException;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;
public class SendMsg_webchinese {
public static void main(String[] args) throws Exception {
HttpClient client = new HttpClient();
PostMethod post = new PostMethod(鈥渉ttp://gbk.sms.webchinese.cn鈥?;
post.addRequestHeader(鈥淐ontent-Type鈥?
鈥渁pplication/x-www-form-urlencoded;charset=gbk鈥?;// 鍦ㄥご鏂囦欢涓缃浆鐮?
NameValuePair[] data = { new NameValuePair(鈥淯id鈥? 鈥滃湪杩欓噷濉啓鍦ㄤ腑鍥界綉寤烘敞鍐岀殑鐢ㄦ埛鍚嶁€?,
new NameValuePair(鈥淜ey鈥? 鈥滃湪姝ゅ~鍐欑綉鍏虫帴鍙e瘑鐮佲€?,
new NameValuePair(鈥渟msMob鈥? 鈥滃湪杩欓噷濉啓鍙戦€佺洰鐨勫湴鎵嬫満鍙封€?,
new NameValuePair(鈥渟msText鈥? 鈥滃湪姝ゅ~鍐欑煭淇″唴瀹光€? };
post.setRequestBody(data);
client.executeMethod(post);
Header[] headers = post.getResponseHeaders();
int statusCode = post.getStatusCode();
System.out.println(鈥渟tatusCode:鈥?+ statusCode);
for (Header h : headers) {
System.out.println(h.toString());
}
String result = new String(post.getResponseBodyAsString().getBytes(
鈥済bk鈥?);
System.out.println(result);
post.releaseConnection();
}
}