胜达短信平台公司

主页 > 短信接口 > 代码示范 > JAVA

[切换]

选择短信群发地区 :北京上海广州深圳
 
          JAVA:
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net. 
public class Send {
   public static String SMS(String postData, String postUrl) {
        try {
            //发送POST请求
           URL url = new URL(postUrl);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
           conn.setRequestMethod("POST");
           conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            conn.setRequestProperty("Connection", "Keep-Alive");
            conn.setUseCaches(false);
            conn.setDoOutput(true);
 
           conn.setRequestProperty("Content-Length", "" + postData.length());
            OutputStreamWriter out = newOutputStreamWriter(conn.getOutputStream(), "UTF-8");
            out.write(postData);
           out.flush();
            out.close();
 
            //获取响应状态
            if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
                System.out.println("connect failed!");
                return "";
            }
            //获取响应内容体
            String line, result = "";
           BufferedReader in = new BufferedReader(newInputStreamReader(conn.getInputStream(), "utf-8"));
            while ((line = in.readLine()) != null) {
                result += line + "\n";
            }
            in.close();
            return result;
        } catch (IOException e) {
            e.printStackTrace(System.out);
       }
        return "";
    }
}
 
java短信接口,jsp调用程序
 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.duanxin66.com">
<html>
    <head>
        <meta http-equiv="Content-Type" content="textml; charset=UTF-8">
       <title>JSP Page</title>
    </head>
    <body>
        <%
            String PostData = "account=帐号&password=接口密码&mobile=手机号码&content="+java.net.URLEncoder.encode("您的订单编码:4557。如需帮助请联系客服。","utf-8");
            //out.println(PostData);
            String ret = cn.umob.sms.Send.SMS
胜达短信群发首页
微信二维码扫一扫
微信联系我们
短信群发网 联系QQ:2321952682 邮箱236815253@qq.com Copyright © 2002-2011 胜达短信平台公司 版权所有 网站地图 XML 网站关键词:短信 短信平台 短信群发 短信接口 短信群发平台