<?php
header("Content-Type: text/html; charset=utf-8");
$post_data = array();
$post_data['account'] = ''; //帐号
$post_data['pswd'] = ''; //密码
$post_data['msg'] =urlencode(''); //短信内容需要用urlencode编码下
$post_data['mobile'] = ''; //手机号码, 多个用英文状态下的 , 隔开
$post_data['product'] = ''; //产品ID
$post_data['needstatus']=true; //是否需要状态报告,需要true,不需要false
$post_data['extno']=''; //扩展码 可以不用填写
$url='http://120.26.69.248/msg/HttpSendSM?account=123456&pswd=123456789&mobile=13200016985&msg=测试PHP&needstatus=true&product=117502&extno=';
$o='';
foreach ($post_data as $k=>$v)
{
$o.="$k=".urlencode($v).'&';
}
$post_data=substr($o,0,-1);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //如果需要将结果直接返回到变量里,那加上这句。
$result = curl_exec($ch);
?>
header("Content-Type: text/html; charset=utf-8");
$post_data = array();
$post_data['account'] = ''; //帐号
$post_data['pswd'] = ''; //密码
$post_data['msg'] =urlencode(''); //短信内容需要用urlencode编码下
$post_data['mobile'] = ''; //手机号码, 多个用英文状态下的 , 隔开
$post_data['product'] = ''; //产品ID
$post_data['needstatus']=true; //是否需要状态报告,需要true,不需要false
$post_data['extno']=''; //扩展码 可以不用填写
$url='http://120.26.69.248/msg/HttpSendSM?account=123456&pswd=123456789&mobile=13200016985&msg=测试PHP&needstatus=true&product=117502&extno=';
$o='';
foreach ($post_data as $k=>$v)
{
$o.="$k=".urlencode($v).'&';
}
$post_data=substr($o,0,-1);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //如果需要将结果直接返回到变量里,那加上这句。
$result = curl_exec($ch);
?>
header("Content-Type: text/html; charset=utf-8");
$post_data = array();
$post_data['account'] ="123456''; //帐号
$post_data['pswd'] ="123456"; //密码
$post_data['msg'] =urlencode(mb_convert_encoding("这是短信内容正文","gb2312","UTF-8"));
//你的短信接口是否要求urlencode我不清楚,但是出现乱码肯定是你的页面的编码和短信接口要求的编码不同(估计短信接口要求gb2312),所以我给你转码了一下;函数参数为:mb_convert_encoding("字符串","目标编码","原始编码")
$post_data['mobile'] ="18688888888''; //手机号码, 多个用英文状态下的 , 隔开
$post_data['product'] = ''; //产品ID
$post_data['needstatus']=true; //是否需要状态报告,需要true,不需要false
$post_data['extno']=''; //扩展码 可以不用填写
$url='http://120.26.69.248/msg/HttpSendSM';
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //如果需要将结果直接返回到变量里,那加上这句。
$result = curl_exec($ch);
?>
这才是curl的post发送短信,你一楼的代码混杂了get和post~~~~如果要用get发送,就没有构造post_data数组了