Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6974069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:11:22+00:00 2026-05-27T17:11:22+00:00

I am using the client side code from http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/Simplified-BIS-Push-client-sample/ta-p/693857 on the BlackBerry Developer Support

  • 0

I am using the client side code from http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/Simplified-BIS-Push-client-sample/ta-p/693857 on the BlackBerry Developer Support forums.

I am able to get a registration response from the BlackBerry push server, however I am unable to get any push messages from the BlackBerry push server. The server side code is built in PHP. When I click on the button send, I obtain this error

---------------error---------------------------------------------
    An XML parser error has occured
    Invalid document end
    Response
---------------PHP code------------------------------------------------------------------
    <?php
    if ($_POST) {
        // APP ID provided by RIM
        $appid = 'xxxxxxxxxx';
        // Password provided by RIM
        $password = 'xxxxxxxxxxxxxxxx';

        //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[] = 'push_all';

        $addresses = '';
        foreach ($addresstosendto as $value) {
            $addresses .= '<address address-value="' . $value . '"/>';
        }

        // create a new cURL resource
        $err = false;
        $ch = curl_init();
        $messageid = microtime(true);

        $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($_POST['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, "Hallgren Networks BB Push Server/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);

        // 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";
        }
    } else {
        showhtml();
    }

    function showhtml() {
        ?>
    <html>
    <head><title>Blackberry PUSH Bishes!!!</title></head>
    <body>
    <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
    <p>Message to push:</p>
    <textarea name="message" rows="30" cols="50"></textarea>
    <p></p><input type="submit" value="Push Data"></p>
    </form>
    </body>
    </html>
    <?php
    }
    ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:11:23+00:00Added an answer on May 27, 2026 at 5:11 pm

    I was able to push messages to my BlackBerry by adding the following line before curl_exec.

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    

    Here is the complete code:

    <?php
    if ($_POST) {
        // APP ID provided by RIM
    
        $appid = 'xxxxxxxxxx';
        // Password provided by RIM
        $password = 'xxxxxxxxxxxxxxxx';
    
        //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[] = 'push_all';
    
        $addresses = '';
        foreach ($addresstosendto as $value) {
            $addresses .= '<address address-value="' . $value . '"/>';
        }
    
        // create a new cURL resource
        $err = false;
        $ch = curl_init();
        $messageid = microtime(true);
    
        $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($_POST['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, "Hallgren Networks BB Push Server/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"));
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    
        // grab URL and pass it to the browser
        $xmldata = curl_exec($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";
        }
    } else {
        showhtml();
    }
    
    function showhtml() {
        ?>
    <html>
    <head><title>Blackberry PUSH Bishes!!!</title></head>
    <body>
    <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
    <p>Message to push:</p>
    <textarea name="message" rows="30" cols="50"></textarea>
    <p></p><input type="submit" value="Push Data"></p>
    </form>
    </body>
    </html>
    <?php
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using some client-side JavaScript code to pull a lot of JSON data from
I'm using this library for Facebook graph API access within my codeigniter project: http://www.haughin.com/code/facebook/
I'm using Client Side templates in my JavaScript. $create(Sys.UI.DataView, { data: data }, null,
Using the client-side ASP.NET AJAX library, I have created an instance of a client
I am using a client side validation and it is starting to get messy,
Sometimes I hear the argument against doing things on client side using javascript. People
How do you return a serialized JSON object to the client side using ASP.NET
Client side form validation becomes easiest by using jQuery. I tried all validators and
I am developing some client side Javascript that is using some JSON web services
I am using GWT for my client side application. I am not using GWT/Java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.