php发送文件示例:
---------------------------------------------------------------------------------------------------------------------------------------
<?php
/*根据参数,生成调用URL,因为是测试例子,不对变量为空的情况做处理*/$http               = "http://www.smsdk.com";  // 接口文件地址
$LoginName     = "";  // 短信帐号
$pass               = "";  // 短信帐号密码
$Code              = "";  // 业务代码,缺省为空
$subid              = "";  // 子号,缺省为空
$sender           = "";  // 发送号码
$receivers       = "";  // 接收号码,多个手机号以分号 ; 分隔
$setTimer        = "";  // 定时发送时间,格式:YYYY-MM-DD HH:MM ,即时发送则不需要
$message        = "";  // 短信内容
$cmd                = "";  // 操作命令,发送短信值为send,查询回复值为query,查询帐号短信余额为remain
$allowForward = "";  // 转发支持,缺省为0$url = $http."?LoginName=".$LoginName."&pass=".$pass."&Code=".$Code."&subid=".$subid."&sender=".$sender."&receivers=".$receivers."&setTimer=".$setTimer."&message=".urlencode($message)."&cmd=".$cmd."&allowForward=".$allowForward;/*调用MSXML,发送请求*/
$objHttpRequest=new COM("MSXML2.ServerXMLHTTP");
if (is_null($objHttpRequest)) {
        echo "create Msxl2.ServerXMLHTTP error";
        exit();        
        }
        
$objHttpRequest->open("GET",$URL,False); 
$objHttpRequest->send();
if ($objHttpRequest->status <> 200) {
/*返回错误*/
        echo "open Request error";
        exit();
        }
        
/*获取返回的信息*/
$retMsg=$objHttpRequest->responseText;/* 根据返回的信息($retMsg,形式如下)获取相应的内容,参数含义请参考“短信接口参数说明”<?xml version="1.0" encoding="utf-8" ?> 
- <SendSmsReport>
- <Summary>
  <Success /> 
  <Fail /> 
  <RetCode>-6</RetCode> 
  <SmsRemain /> 
  <ErrPhones /> 
  </Summary>
  </SendSmsReport>*/
        
/*释放对象*/
$objHttpRequest=NULL;
?> php短信接口源码,参数说明 
 一、例1$loginname = ""; // 接口帐号
$pass = ""; // 接口密码
$code = "";
$subid = "";
$sender = "";
$receivers = ""; // 接收号码,多个号码间用 ; 分隔
$settimer = ""; // 定时发送时间 格式:YYYY-MM-DD HH:MM
$message = urlencode("");
$cmd = "send";
$allowforward = "";
$recordid_client = ""; // 短信的客户端记录号$http = "http://interface.37du.net/interface_sms_url.ajax";
$file = $http."?loginname=".$loginname."&pass=".$pass."&code=".$code."&subid=".$subid."&sender=".$sender."&receivers=".$receivers."&settimer=".$settimer."&message=".$message."&cmd=".$cmd."&allowforward=".$allowforward."&recordid_client=".$recordid_client;$xml = new XMLReader();
$xml->open($file);
$xml->setParserProperty(2,true);
while ($xml->read()) {
switch ($xml->name) {
case "Success": $xml->read();
$Success = $xml->value;
$xml->read();
break;
case "Fail": $xml->read();
$Fail = $xml->value;
$xml->read();
break;
case "RetCode": $xml->read();
$RetCode = $xml->value;
$xml->read();
break;
case "SmsRemain": $xml->read();
$SmsRemain = $xml->value;
$xml->read();
break;
case "ErrPhones": $xml->read();
$ErrPhones = $xml->value;
$xml->read();
break;
}
}
$xml->close();
// $Success 发送成功条数
// $Fail 发送失败条数
// $RetCode 发送状态值
// $SmsRemain 接口帐号余额
// $ErrPhones 发送失败号码 二、例2* 短信接口文件:
<?php/*根据参数,生成调用URL,因为是测试例子,不对变量为空的情况做处理*/$http = "http://interface.85521.com/interface_sms_url.ajax"; // 接口文件地址
$LoginName = ""; // 短信帐号
$pass = ""; // 短信帐号密码
$Code = ""; // 业务代码,缺省为空
$subid = ""; // 子号,缺省为空
$sender = ""; // 发送号码
$receivers = ""; // 接收号码,多个手机号以分号 ; 分隔
$setTimer = ""; // 定时发送时间,格式:YYYY-MM-DD HH:MM ,即时发送则不需要
$message = ""; // 短信内容
$cmd = ""; // 操作命令,发送短信值为send,查询回复值为query,查询帐号短信余额为remain
$allowForward = ""; // 转发支持,缺省为0
$system = ""; // 应用平台,缺省为空(windows),其他平台值:unix或linux$url = $http."?LoginName=".$LoginName."&pass=".$pass."&Code=".$Code."&subid=".$subid."&sender=".$sender."&receivers=".$receivers."&setTimer=".$setTimer."&message=".urlencode($message)."&cmd=".$cmd."&allowForward=".$allowForward."&system=".$system;/* windows平台调用接口形式:MSXML,发送请求*/
// ----------------------------------------------------------------------------
$objHttpRequest=new COM("MSXML2.ServerXMLHTTP");
if (is_null($objHttpRequest)) {
echo "create Msxl2.ServerXMLHTTP error";
exit();
}
$objHttpRequest->open("GET",$URL,False);
$objHttpRequest->send();
if ($objHttpRequest->status <> 200) {
/*返回错误*/
echo "open Request error";
exit();
}
/*获取返回的信息*/
$retMsg=$objHttpRequest->responseText;
$objHttpRequest=NULL;
// ----------------------------------------------------------------------------
/* 通用调用用接口形式,(其他平台linux、unix)*/
// ----------------------------------------------------------------------------
$file = $http."?LoginName=".$LoginName."&pass=".$pass."&Code=".$Code."&subid=".$subid."&sender=".$sender."&receivers=".$receivers."&setTimer=".$setTimer."&message=".urlencode($message)."&cmd=".$cmd."&allowForward=".$allowForward."&system=".$system;
$fp = fopen($file,"r");
$retMsg = fgetss($fp); // $retMsg = fgetss($fp,1024);
fclose($fp);
// ----------------------------------------------------------------------------
/* 根据返回的信息($retMsg,形式如下)获取相应的内容,参数含义请参考“短信接口参数说明”
windows平台返回形式如下:<?xml version="1.0" encoding="utf-8" ?>
- <SendSmsReport>
- <Summary>
<Success />
<Fail />
<RetCode>-6</RetCode>
<SmsRemain />
<ErrPhones />
</Summary>
</SendSmsReport>其他平台返回形式如下:[SendSmsReport]
[Summary]
[Success][/Success]
[Fail][/Fail]
[RetCode]-6[/RetCode]
[SmsRemain][/SmsRemain]
[ErrPhones][/ErrPhones]
[/Summary]
[/SendSmsReport]*/
?>

解决方案 »

  1.   


    他难于在CSDN做广告
      

  2.   

    其实不用飞信短信代码,你只要安装了基于php的飞信的开发包及其相关的技术手册,就能开发了。查看相关的demo和手册就能快速开发了,祝你成功。
      

  3.   


    接口使用启明应用服务类信息发送引擎。使用需登陆www.qimingsoft.com注册,新用户赠送10条短信 
    内容来自:http://www.qimingsoft.com/contents/10/54.html
    file_get_contents版: <?php
     function Post($url, $post)
     {
     $context = array();
     if (is_array($post))
     {
     ksort($post);
     $context['http'] = array
     ( 
    'timeout'=>60,
     'method' => 'POST',
     'content' => http_build_query($post, '', '&'),
     );
     }
     return file_get_contents($url, false, stream_context_create($context));//如果调用失败请确认"fopen wrappers”已经被激活
     }function SendSMS($mobile,$Tempid,$pars)
     {
     $data = array
     (
     'op' => 'sendsms',
     'username' => 'test', //你的短信帐户。新开户请到www.qimingsoft.com注册
     'password' => 'test', //短信帐户的密码
     'mobile'=>$mobile,
     'msgtempid'=>$Tempid,
     'pras' => $pars
     );
     return Post('http://0752.soohz.com:8080/Appsdk.aspx', $data);
     }
     echo SendSMS('13800138000','1','username=张三先生,ID=123456');//参数名依次为:接收号码,短信模板ID,模板参数名?> CURL版:在无法使用 file_get_contents版时可以选用此版本:<?php
     $target = "http://0752.soohz.com:8080/appsdk.aspx";
     $username="test123";
     $password="123456";
     function sendsms($target,$username,$password,$mobile,$tempid,$pars)
     {
     $url = $target."?Op=sendsms&username=".$username."&password=".$password."&mobile=".$mobile."&msgtempid=".$tempid."&pras=".$pars;
     $ch = curl_init();
     $timeout = 5;
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
     $contents = curl_exec($ch);
     curl_close($ch);
     return $contents;
     }
     echo sendsms($target,$username,$password,"13800138000",1,"username|张三先生,pin|119875");
     ?>