Function Post(url,data)
dim Https
set Https=server.createobject("MSXML2.XMLHTTP")
Https.open "POST",url,false
Https.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
Https.send data
if Https.readystate=4 then
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write Https.responseBody
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "gb2312"
Post = objstream.ReadText
objstream.Close
set objstream = nothing
set https=nothing
end if
End Function
dim target,post_data
userName = "帐号"
PassWord = "密码"
Mobile = "15574888434"
Content = "您好,您的验证码是884192【中正云通信】"
target = "https://service.winic.org/sys_port/gateway/index.asp?"
post_data = "id="&userName&"&pwd="&PassWord&"&to="&Mobile&"&content="&Server.URLEncode(Content)&"&time="
response.Write(Post(target,post_data))
$randStr = str_shuffle('1234567890');
$code = substr($randStr,0,4);
$content = "你的验证码是:".$code."【中正云通信】";
$mobile = "手机号码";
function NewSms($mobile,$content){
$url="https://service.winic.org/sys_port/gateway/index.asp?";
$data = "id=%s&pwd=%s&to=%s&Content=%s&time=";
$id = urlencode(iconv("utf-8","gb2312","帐号"));
$pwd = '密码';
$to = $mobile;
$content = urlencode(iconv("UTF-8","GB2312",$content));
$rdata = sprintf($data, $id, $pwd, $to, $content);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$rdata);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
echo NewSms($mobile,$content);
private void button1_Click_1(object sender, EventArgs e)
{
string uid = t_uid.Text.Trim();
string pwd = t_pwd.Text.Trim();
string mob = t_mob.Text.Trim();
string msg = t_msg.Text.Trim();
url = "https://service.winic.org/sys_port/gateway/index.asp?";
data = "id=" + uid + "&pwd=" + pwd + "&to=" + mob + "&content=" + msg + "&time=";
string backinfo = PostData(url, data);
vtag.Text = backinfo;
}
public static string PostData(string purl,string str){
try{
byte[] data = System.Text.Encoding.GetEncoding("GB2312").GetBytes(str);
// 准备请求
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(purl);
//设置超时
req.Timeout = 30000;
req.Method = "Post";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = data.Length;
Stream stream = req.GetRequestStream();
// 发送数据
stream.Write(data, 0, data.Length);
stream.Close();
HttpWebResponse rep = (HttpWebResponse)req.GetResponse();
Stream receiveStream = rep.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("UTF-8");
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader(receiveStream, encode);
Char[] read = new Char[256];
int count = readStream.Read(read, 0, 256);
StringBuilder sb = new StringBuilder("");
while (count > 0)
{
String readstr = new String(read, 0, count);
sb.Append(readstr);
count = readStream.Read(read, 0, 256);
}
rep.Close();
readStream.Close();
return sb.ToString();
}
catch (Exception ex)
{
return "posterror";
}
}
public static String HTTP_POST(String URL, String Data) throws Exception {
BufferedReader In = null;
PrintWriter Out = null;
HttpURLConnection HttpConn = null;
try {
URL url=new URL(URL);
HttpConn=(HttpURLConnection)url.openConnection();
HttpConn.setRequestMethod("POST");
HttpConn.setDoInput(true);
HttpConn.setDoOutput(true);
Out=new PrintWriter(HttpConn.getOutputStream());
Out.println(Data);
Out.flush();
if(HttpConn.getResponseCode() == HttpURLConnection.HTTP_OK){
StringBuffer content = new StringBuffer();
String tempStr = "";
In = new BufferedReader(new InputStreamReader(HttpConn.getInputStream()));
while((tempStr = In.readLine()) != null){
content.append(tempStr);
}
In.close();
return content.toString();
}
else
{
throw new Exception("HTTP_POST_ERROR_RETURN_STATUS:" + HttpConn.getResponseCode());
}
} catch (IOException e) {
e.printStackTrace();
}finally{
Out.close();
HttpConn.disconnect();
}
return null;
}
public static void main(String[] args) throws Exception{
String HTTP_BACK_MESSAGE = "";
url = "https://service.winic.org/sys_port/gateway/index.asp";
data = "id=帐号&pwd=密码&to=手机号码&content=" + URLEncoder.encode("您的验证码是884192【签名】", "gb2312") + "&time="
HTTP_BACK_MESSAGE = HTTP_POST(url, data);
System.out.println(HTTP_BACK_MESSAGE);
}
string ls_result
integer li_rc
inet linet_main
n_cst_internet luo_data
linet_main = CREATE inet
luo_data = CREATE n_cst_internet
url = 'https://service.winic.org/sys_port/gateway/index.asp?'
SetPointer(HourGlass!)
li_rc = linet_main.GetURL(url+"id=帐号&pwd=密码&to=手机&content=您好,您的验证码是884192【中正云】&time=", luo_data)
SetPointer(Arrow!)
ls_result = luo_data.is_data
Messagebox("",ls_result)
DESTROY luo_data
DESTROY linet_main
return ls_result
// 注意引用 uses comobj
//_________________________________HTTP通信函数返回信息
function HTTPwebservice(url:string):string;
var
responseText: WideString;
xmlHttp: OLEVariant;
begin
try
xmlHttp:=CreateOleObject('Msxml2.XMLHTTP');
xmlHttp.open('GET',url,false);
xmlHttp.send();
responseText:=xmlHttp.responseText;
if xmlHttp.status='200' then
begin
HTTPwebservice:=responseText;
end;
xmlHttp := Unassigned;
except
exit;
end;
end;
//______________________________
//使用时调用即可
url:='http://service.winic.org/sys_port/gateway/?';
bdata:=HTTPwebservice(url+'id='+uid.Text+'&pwd='+pwd.Text+'&to='+mobstr+'&content='+content.Text+'&time=');
int basefd;
char *hostname = "service.winic.org";
char *send_sms_uri = "/sys_port/gateway/index.asp";
ssize_t http_post(char *page, char *poststr)
{
char sendline[MAXLINE + 1], recvline[MAXLINE + 1];
ssize_t n;
snprintf(sendline, MAXSUB,
"POST %s HTTP/1.0\r\n"
"Host: %s\r\n"
"Content-type: application/x-www-form-urlencoded\r\n"
"Content-length: %zu\r\n\r\n"
"%s", page, hostname, strlen(poststr), poststr);
write(basefd, sendline, strlen(sendline));
while ((n = read(basefd, recvline, MAXLINE)) > 0) {
recvline[n] = '\0';
printf("%s", recvline);
}
return n;
}
ssize_t send_sms(char *id, char *pwd, char *to, char *content)
{
char params[MAXPARAM + 1];
char *cp = params;
sprintf(cp,"id=%s&pwd=%s&to=%s&content=%s&time=", id, pwd, to, content);
return http_post(send_sms_uri, cp);
}
int socked_connect(char *arg)
{
struct sockaddr_in their_addr = {0};
char buf[1024] = {0};
char rbuf[1024] = {0};
char pass[128] = {0};
struct hostent *host = NULL;
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
if(sockfd<0)
{
printf ("create the sockfd is failed\n");
return -1;
}
if((host = gethostbyname(arg))==NULL)
{
printf("Gethostname error, %s\n");
return -1;
}
memset(&their_addr, 0, sizeof(their_addr));
their_addr.sin_family = AF_INET;
their_addr.sin_port = htons(80);
their_addr.sin_addr = *((struct in_addr *)host->h_addr);
if(connect(sockfd,(struct sockaddr *)&their_addr, sizeof(struct sockaddr)) < 0)
{
close(sockfd);
return -1;
}
printf ("connect is success\n");
return sockfd;
}
int main(void)
{
struct sockaddr_in servaddr;
char str[50];
sockfd = socket(AF_INET, SOCK_STREAM, 0);
bzero(&servaddr, sizeof(servaddr));
servaddr.sin_addr =*(hostname);
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(80);
inet_pton(AF_INET, str, &servaddr.sin_addr);
connect(sockfd, (SA *) & servaddr, sizeof(servaddr));
#endif
if((basefd= socked_connect(hostname))==-1)
{
printf("connect is failed\n");
return -1;
}
printf("basefd is =%d\n",basefd);
char *id = "帐号";
char *pwd = "密码";
char *to = "18000000000";
char *content = "您好,您的验证码是884192【中正云通信】";
send_sms(id, pwd, to, content);
printf("send the message is success\n");
close(basefd);
exit(0);
}