ecshop短信服务开通

来源:互联网 发布:路由器支持网络尖兵 编辑:程序博客网 时间:2024/04/30 16:30

目前,市场上有很多家提供短信服务的商家,这里没有使用ecshop自带的短信接口,本人试过shopEx的短信服务,开通后免费赠送的20条短信一条都发不出去。所以,在这里推荐畅卓短信接口,对接也非常简单。

首先,开通下单时短信通知,找到网站根目录下的flow.php,找到如下代码:if ($_CFG['sms_order_placed'] == '1' && $_CFG['sms_shop_mobile'] != '');把后面大括号里面的代码替换成如下代码:

$target = "http://sms.chanzor.com:8001/sms.aspx";
//替换成自己的测试账号,参数顺序和wenservice对应
$post_data = "action=send&userid=&account=账号&password=密码&mobile=".$order['mobile']."&sendTime=&content=".rawurlencode("短信内容");
//$binarydata = pack("A", $post_data);
$gets = Post($post_data, $target);

这里解释一下,$post_data后面的账号、密码是畅卓的销售人员提供给你的,短信内容是跟销售人员报备的内容,不是随便乱填的。

并在文件末尾加上代码:

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;
}

这样,下单短信通知就开通了。

如果还想开通发货时短信通知,方法类似,在/admin/order.php中,找到如下代码:if ($GLOBALS['_CFG']['sms_order_shipped'] == '1' && $order['mobile'] != '')

把整个if语句(包括后面大括号里的)替换成如下代码:

if ($_CFG['sms_order_shipped'] == '1' && $_CFG['sms_shop_mobile'] != '')
{

$target = "http://sms.chanzor.com:8001/sms.aspx";
//替换成自己的测试账号,参数顺序和wenservice对应
$post_data = "action=send&userid=&account=账号&password=密码&mobile=".$order['mobile']."&sendTime=&content=".rawurlencode("短信内容");
//$binarydata = pack("A", $post_data);
$gets = Post($post_data, $target);
}

这里解释一下,$post_data后面的账号、密码是畅卓的销售人员提供给你的,短信内容是跟销售人员报备的内容,不是随便乱填的。

同样,在文件末尾加上代码:

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;
}

这样,发货短信通知就开通了。

本人已经开通成功,希望对还不太清楚的朋友有所帮助。
1 0
原创粉丝点击