PPG mini HOWTO!!! :)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

PPG mini HOWTO!!! :)

Juan Nin
Well, as I promised here's an ultra mini PPG Howto  :P

Actually the Kannel's doc is not that bad as I thought. What should be
maybe  explained a bit more is the part of posting the data to the PPG
server.

The configuration was done following tha Kannel's doc.
Having a running kannel box with smsbox, sms-services, etc, these are
the steps I followed:


First I added to my existing kannel.conf under core gorup:

wapbox-port    = xxxx


where xxxx is the port obviously  :)

Then I added wapbox group which I din't use:


group           = wapbox
bearerbox-host  = localhost
log-file        = "/var/log/kannel/wapbox.log"
log-level       = 1
syslog-level    = none


After that I added ppg group:


group             = ppg
ppg-url           = /wappush
ppg-port          = 8080
concurrent-pushes = 100
users             = 1024
ppg-allow-ip      = "xxx.xxx.xxx.xxx"
trusted-pi        = true
service-name      = ppg1

group           = wap-push-user
wap-push-user   = wappush
ppg-username    = foo
ppg-password    = bar
allow-ip        = "xxx.xxx.xxx.xxx"


Restart kannel, and that's it  :)

Actually as I put "trusted-pi = true" the PPG server won't check for the
username and password from wap-push-user group
It's maybe better first doing it this way, and if it works fine, then go
and use the user and password

For sending the Wap Push itself here I post some PHP code. It's just a
simple function for you to see how to send it,
as proof of concept, and you may adapt it to your needs, including the
XML's parameters used.

Since I'm not using right now the authentication part (trusted-pi =
true), I left the authentication part on
the code commented. I haven't tested it with wap-push-user yet, but
uncommenting the $ppg_user and $ppg_pass variables
plus uncommenting the "Authorization: Basic" line I guess it should work
fine, if you use "trusted-pi = false" plus wap-push-user

I'm making use of CURL for posting to the PPG server.


The only thing is that I'm succesfully sending Wap Push via PPG now, and
the phones receive them fine, but on the
wapbox logs I find this warning:

WARNING: Received other message than wdp/admin, ignoring!

I've seen a couple of mails on the list asking about this, but now
answer about it... and no idea of what it is about..
Anyone knows what's this warning about???

So here's the code!
Have fun!

Cheers,

Juan


<?

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

send_wap_push($smsc_id, $country_code, $phone, $url, $text);


function send_wap_push($smsc_id, $country_code, $phone, $push_url, $text)
{
        $host = 'xxx.xxx.xxx.xxx';
        $port = '8080';
        $url  =  "<a href="http://$host:$port">http://$host:$port";
       
        //$ppg_user = 'foo';
        //$ppg_pass = 'bar';
       
        $wap_push_id = 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=[hidden email]"/>'."\r\n".
                        '<quality-of-service delivery-method="unconfirmed" network="GSM"
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-high" si-id="'.$wap_push_id.'"
href="'.$push_url.'">'.$text.'</indication>'."\r\n".
                        "</si>\r\n".
                        "--multipart-boundary--\r\n";

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

?>









Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PPG mini HOWTO!!! :)

Juan Nin
if anyone finds something wrong on what I'm doing for PPG,
or wants to contribute on anything, feel free to post about it  ;)

Regards,

Juan

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PPG mini HOWTO!!! :)

Aarno Syvanen
Great ! can I add it tp userguide ? People seems have similar  
problems ...

Aarno

On 21 Jan 2006, at 00:20, Juan Nin wrote:

> if anyone finds something wrong on what I'm doing for PPG,
> or wants to contribute on anything, feel free to post about it  ;)
>
> Regards,
>
> Juan
>


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PPG mini HOWTO!!! :)

Juan Nin
sure!  :)

Aarno Syvänen wrote:

> Great ! can I add it tp userguide ? People seems have similar  problems ...
>
> Aarno
>
> On 21 Jan 2006, at 00:20, Juan Nin wrote:
>
>> if anyone finds something wrong on what I'm doing for PPG,
>> or wants to contribute on anything, feel free to post about it  ;)
>>
>> Regards,
>>
>> Juan
>>
>
>


Loading...