douxian1895 2019-01-31 06:08
浏览 73

WAP PUSH WITH KANNEL

I want to send a wap push message which contains a url. When the phone receives that message it should not be an SMS. When I tap the message it should open the url. And it is better the message will not be stored in the inbox. I am tring it with OPPO A7 mobile phone.

This is the php code i use. With this code message is received as an SMS. If I tap only the URL part it will go to that url. If I tap the notification messaging app is opened.

What can I do to get my job done? Thank you for any help

<?php

$country_code = '94';
$phone = '77383xxxx';
$push_url = 'http://wap.google.com';
//$text = 'This is a test';
$smsc_id  = 'mySMSCid';

//echo "start0";
send_wap_push($smsc_id, $country_code, $phone, $push_url, $text);


function send_wap_push($smsc_id, $country_code, $phone, $push_url, $text)
{
//$push_url = 'http://wap.google.com';
//echo $push_url;
//echo "start
";
$text = 'XXXXXXXX International';
        $host = '172.16.10.20';
        $port = '10166';
        //$url  =  '<a href="http://$host:$port">http://$host:$port';
    $url  =  "http://$host:$port/wappush";

        //$ppg_user = 'foo';
        //$ppg_pass = 'bar';

        $wap_push_id = 2234567;    //function_that_generates_a_unique_id();

        $body =    "--multipart-boundary
".
                        "Content-type: application/xml

".
                        '<?xml version="1.0"?>'."
".
                        '<!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 1.0//EN"'."
".
                        '"http://www.wapforum.org/DTD/pap_1.0.dtd" >'."
".
                        '<pap>'."
".
                        '<push-message push-id="'.$wap_push_id.'">'."
".
                        '<address address-value="WAPPUSH=+'.$country_code.$phone.'/TYPE=PLMN@ppg.carrier.com"/>'."
".
                        '<quality-of-service delivery-method="unconfirmed" network-required="true" network="GSM" bearer-required="true" bearer="SMS"/>'.
                        "</push-message>
".
                        "</pap>

".
                        "--multipart-boundary
".
                        "Content-type: text/vnd.wap.si

".
                        '<?xml version="1.0"?>'."
".
                        '<!DOCTYPE si PUBLIC "-//WAPFORUM//DTD SI 1.0//EN"'."
".
                        '"http://www.wapforum.org/DTD/si.dtd">'."
".
                        "<si>
".
                        '<indication action="signal-medium" si-expires="2020-01-30T13:23:00Z" si-id="'.$wap_push_id.'" href="'.$push_url.'">'.$text.'</indication>'."
".
                        "</si>
".
                        "--multipart-boundary--
";
echo "here1
";
echo $body;
        $post = "POST /wappush HTTP/1.1
".
                        "Host: $host:$port
".
                        //"Authorization: Basic ".base64_encode("$ppg_user:$ppg_pass")."
";
                        "X-Kannel-SMSC: $smsc_id
".
                        'Content-Type: multipart/related; boundary=multipart-boundary; type="application/xml"'."
".
                        "Content-Length: ".strlen($body)."
".
                        "
".
                        $body;

        $ch = curl_init();
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 15);
        curl_setopt ($ch,CURLOPT_CUSTOMREQUEST , $post);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $reply = curl_exec($ch);
        curl_close ($ch);

        print_r($reply);
    print_r("done"); 
}

?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
    • ¥65 汇编语言除法溢出问题
    • ¥15 Visual Studio问题
    • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
    • ¥20 求一个html代码,有偿
    • ¥100 关于使用MATLAB中copularnd函数的问题
    • ¥20 在虚拟机的pycharm上
    • ¥15 jupyterthemes 设置完毕后没有效果
    • ¥15 matlab图像高斯低通滤波
    • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗