首页 > 开发 > PHP > 正文

php写的短信接口(全网支持)

2024-05-04 22:59:52
字体:
来源:转载
供稿:网友


  • 适用行业:金融、工商、税务、电力、贸易、商业、旅游、政府、邮政、教育等行业

    适用类型:挂接各种b/s系统,作为各类办公系统、erp、crm、电子商务平台的插件(如群发短信会议通知、会员/客户关系交流、订单生成通知、发货通知、日程提醒、催费通知等等)

    特 点: 绿色短信,合法正规通道,全网收发
    支持移动、联通、电信、网通短信,双向互动,可回复 高速群发

    免费帐号申请(请注明来自"chinaunix",赠送50条短信,测试短信不够用的话再联系我)
    qq:670168401(申请帐号) qq群:199217(短信接口应用交流)


    * 短信url接口详细参数说明文件: http://app.37du.net/短信url接口参数说明.doc

    * 短信接口文件:
    <?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]

    */
    ?>
  • 发表评论 共有条评论
    用户名: 密码:
    验证码: 匿名发表