Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

BlackBerry Push Development

Reply
Developer
ankit2grover
Posts: 159
Registered: ‎08-19-2008
My Device: Not Specified

Cannot send PHP Push message using Blackberry Push Essentials service

I tried to send push notification using my application through PHP PAP Push for Blackberry Push  Essentials service .

 

Following credentials were provided after regisration to RIM


Application ID - App id provided by RIM
Server Password - App password provided by RIM
BlackBerry PIN[on which have to send message]
Notification Message -"test Message"

Incorporated all these credentials with PHP code , code was taken  from  this url  -

http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/Push-API-sample-code-needed/m-p/4...

But, getting Access Forbidden error message.

If anyone have idea to fix the issue. Please guide.

Any kind of help would be appreciated.

Please use plain text.
New Contributor
lcarpenter
Posts: 8
Registered: ‎06-28-2010
My Device: Bold 9700
My Carrier: O2 UK

Re: Cannot send PHP Push message using Blackberry Push Essentials service

Hiya,

 

Whereabouts have you set the port?

As I am attempting to use that script and can't find a place to put it.

 

Luke Carpenter

Please use plain text.
Developer
ankit2grover
Posts: 159
Registered: ‎08-19-2008
My Device: Not Specified

Re: Cannot send PHP Push message using Blackberry Push Essentials service

Iam using following php script at server for sending push messages

 

<?
    // APP ID provided by RIM
    $appid = '';
     
    // Password provided by RIM
    $password = '';
    
    //Deliver before timestamp
    $deliverbefore = gmdate('Y-m-d\TH:i:s\Z', strtotime('+5 minutes'));
    
    //An array of address must be in PIN format or "push_all"
    $addresstosendto[] = '';
    
    $addresses = '';
    foreach ($addresstosendto as $value) {
        $addresses .= '<address address-value="' . $value . '"/>';
    }
    
    // create a new cURL resource
    $err = false;
    $ch = curl_init();
    $messageid = microtime(true);
    $message = 'BlackBerry push service test';

    $data = '--mPsbVQo0a68eIL3OAxnm'. "\r\n" .
    'Content-Type: application/xml; charset=UTF-8' . "\r\n\r\n" .
    '<?xml version="1.0"?>
    <!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 2.1//EN" "http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd">
    <pap>
    <push-message push-id="' . $messageid . '" deliver-before-timestamp="' . $deliverbefore . '" source-reference="' . $appid . '">'
    . $addresses .
    '<quality-of-service delivery-method="unconfirmed"/>
    </push-message>
    </pap>' . "\r\n" .
    '--mPsbVQo0a68eIL3OAxnm' . "\r\n" .
    'Content-Type: text/plain' . "\r\n" .
    'Push-Message-ID: ' . $messageid . "\r\n\r\n" .
    stripslashes($message) . "\r\n" .
    '--mPsbVQo0a68eIL3OAxnm--' . "\n\r";

    // set URL and other appropriate options
 
    curl_setopt($ch, CURLOPT_URL, "https://pushapi.eval.blackberry.com/mss/PD_pushRequest");
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_USERAGENT, "BlackBerry Push Service SDK/1.0");
    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_USERPWD,$appid.':'.$password );
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: multipart/related; boundary=mPsbVQo0a68eIL3OAxnm; type=application/xml", "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2", "Connection: keep-alive"));

    // grab URL and pass it to the browser
    $xmldata = curl_exec($ch);
    $result_info = curl_getinfo($ch);
    
    // close cURL resource, and free up system resources
    curl_close($ch);
    
    //Start parsing response into XML data that we can read and output
    $p = xml_parser_create();
    xml_parse_into_struct($p, $xmldata, $vals);
    $errorcode = xml_get_error_code($p);
    if ($errorcode > 0) {
        $err = true;
    }
    xml_parser_free($p);

    echo 'Our PUSH-ID: ' . $messageid . "<br \>\n";
    if (!$err && $vals[1]['tag'] == 'PUSH-RESPONSE') {
        echo 'PUSH-ID: ' . $vals[1]['attributes']['PUSH-ID'] . "<br \>\n";
        echo 'REPLY-TIME: ' . $vals[1]['attributes']['REPLY-TIME'] . "<br \>\n";
        echo 'Response CODE: ' . $vals[2]['attributes']['CODE'] . "<br \>\n";
        echo 'Response DESC: ' . $vals[2]['attributes']['DESC'] . "<br \> \n";
    } elseif ($err) {
        echo '<p>An XML parser error has occured</p>' . "\n";
        echo '<pre>' . xml_error_string($errorcode) ."</pre>\n";
        echo '<p>Response</p>' . "\n";
        echo '<pre>' . $xmldata . '</pre>' . "\n";
    } else {
        echo '<p>An error has occured</p>' . "\n";
        echo 'Error CODE: ' . $vals[1]['attributes']['CODE'] . "<br \>\n";
        echo 'Error DESC: ' . $vals[1]['attributes']['DESC'] . "<br \>\n";
    }

?>

 

 

As per my knowledge there is no need for providing port no at server application , it is used for device side.

 

Can you or anyone else tell me as per my code what am doing wrong or any settings needs to be done...........?

 

Any kind of help would be appreciated..........

Please use plain text.
New Contributor
lcarpenter
Posts: 8
Registered: ‎06-28-2010
My Device: Bold 9700
My Carrier: O2 UK

Re: Cannot send PHP Push message using Blackberry Push Essentials service

Sorry, I have only just started using BlackBerry Developer Services, and my only other suggestion is if the server has multiple IP addresses assigned to it, which one is the PHP package bound to?

 

Luke Carpenter

Please use plain text.
Developer
ankit2grover
Posts: 159
Registered: ‎08-19-2008
My Device: Not Specified

Re: Cannot send PHP Push message using Blackberry Push Essentials service

Is there anyone else who can guide me why it is not working.........?

Please use plain text.
New Developer
shendz
Posts: 13
Registered: ‎05-23-2010
My Device: 8900
My Carrier: T-Mobile

Re: Cannot send PHP Push message using Blackberry Push Essentials service

That script is from another post, correct?

I am using that script and looks like it works.

At least Blackberry Push Proxy server returns something to me, that I don't have any subscribers yet.

Have you applied for Push Essentials account? If you did, you will get feedback via email with your password, application id, etc, pieces information you need in order for that PHP script to work.

I remember you just need to specify appid and password.

 

I am struggling in getting subscription works.

Does anyone get subscription work? Registering your Blackberry device to Blackberry Push Proxy server that is.

Please use plain text.
Contributor
1llus1on
Posts: 19
Registered: ‎06-23-2010
My Device: Bold
My Carrier: Indonesia

Re: Cannot send PHP Push message using Blackberry Push Essentials service

Hmm, I dun know if this is working or not..

 

1. Try to push from the same IP address that you use when register to RIM

2. Use server password, not application password...

 

Hope its work...

 

If you thinks this post usefull.. You can give me kudos^^

Please use plain text.
Contributor
1llus1on
Posts: 19
Registered: ‎06-23-2010
My Device: Bold
My Carrier: Indonesia

Re: Cannot send PHP Push message using Blackberry Push Essentials service

Hmm... I already try this too.. But my response not same as you got...

 

I got this response :

 

Our PUSH-ID: 1278069599.5781

An XML parser error has occured

Invalid document end

Response

 

Can anyone tell me what does it mean??

 

Thanks ^^

Please use plain text.
Contributor
1llus1on
Posts: 19
Registered: ‎06-23-2010
My Device: Bold
My Carrier: Indonesia

Re: Cannot send PHP Push message using Blackberry Push Essentials service

Does anyone know how to modif this code, so I can send a data with an image too??

 

Thanks for helping...

Please use plain text.
Developer
raquibulbari
Posts: 137
Registered: ‎09-30-2009
My Device: Torch 9800

Re: Cannot send PHP Push message using Blackberry Push Essentials service

I am also getting the same error. Does anyone have a solution for this?

----------------------
Press like if you find a message helpful
---------
Please use plain text.