我想发送一个包含URL的wap推送消息。当电话收到该消息时,它不应是SMS。当我点击消息时,应该打开网址。而且最好不要将邮件存储在收件箱中。我正在用OPPO A7手机试用它。
这是我使用的php代码。带有此代码的消息以SMS形式接收。如果我仅点击URL部分,它将转到该URL。如果我点击该通知消息应用程序已打开。
我该怎么做才能完成工作?谢谢您的帮助
<?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\n";
$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\r\n".
"Content-type: application/xml\r\n\r\n".
'<?xml version="1.0"?>'."\r\n".
'<!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 1.0//EN"'."\r\n".
'"http://www.wapforum.org/DTD/pap_1.0.dtd" >'."\r\n".
'<pap>'."\r\n".
'<push-message push-id="'.$wap_push_id.'">'."\r\n".
'<address address-value="WAPPUSH=+'.$country_code.$phone.'/TYPE=PLMN@ppg.carrier.com"/>'."\r\n".
'<quality-of-service delivery-method="unconfirmed" network-required="true" network="GSM" bearer-required="true" bearer="SMS"/>'.
"</push-message>\r\n".
"</pap>\r\n\r\n".
"--multipart-boundary\r\n".
"Content-type: text/vnd.wap.si\r\n\r\n".
'<?xml version="1.0"?>'."\r\n".
'<!DOCTYPE si PUBLIC "-//WAPFORUM//DTD SI 1.0//EN"'."\r\n".
'"http://www.wapforum.org/DTD/si.dtd">'."\r\n".
"<si>\r\n".
'<indication action="signal-medium" si-expires="2020-01-30T13:23:00Z" si-id="'.$wap_push_id.'" href="'.$push_url.'">'.$text.'</indication>'."\r\n".
"</si>\r\n".
"--multipart-boundary--\r\n";
echo "here1\n";
echo $body;
$post = "POST /wappush HTTP/1.1\r\n".
"Host: $host:$port\r\n".
//"Authorization: Basic ".base64_encode("$ppg_user:$ppg_pass")."\r\n";
"X-Kannel-SMSC: $smsc_id\r\n".
'Content-Type: multipart/related; boundary=multipart-boundary; type="application/xml"'."\r\n".
"Content-Length: ".strlen($body)."\r\n".
"\r\n".
$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");
}
?>