DEMO演示


PHPDEMO下载



代码示例1:sms.php 文件 
     
function Post($data, $target) { 
    $url_info = parse_url($target); 
    $httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n"; 
    $httpheader .= "Host:" . $url_info['host'] . "\r\n"; 
    $httpheader .= "Content-Type:application/x-www-form-urlencoded\r\n"; 
    $httpheader .= "Content-Length:" . strlen($data) . "\r\n"; 
    $httpheader .= "Connection:close\r\n\r\n"; 
    //$httpheader .= "Connection:Keep-Alive\r\n\r\n"; 
    $httpheader .= $data; 
     
    $fd = fsockopen($url_info['host'], 80); 
    fwrite($fd, $httpheader); 
    $gets = ""; 
    while(!feof($fd)) { 
        $gets .= fread($fd, 128); 
    } 
    fclose($fd); 
    return $gets; 
}[/code]参数整理及调用: 

代码示例2:调用发送
              
include_once('sms.php');
                
$target = "http://sms.chanzor.com:8001/sms.aspx";
//替换成自己的测试账号,参数顺序和wenservice对应
$post_data = "action=send&userid=&account=账号&password=密码&mobile=手机号&sendTime=&content=".rawurlencode("短信内容");
//$binarydata = pack("A", $post_data);
$gets = Post($post_data, $target);
$start=strpos($gets,"<?xml");
$data=substr($gets,$start);
$xml=simplexml_load_string($data);
var_dump(json_decode(json_encode($xml),TRUE));
//请自己解析$gets字符串并实现自己的逻辑
//<State>0</State>表示成功,其它的参考文档
其他语言包DEMO下载