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");
}
?>