I have successfully getting registration id (pin) from my device, but i stuck on server side development, I hope someone could help me :Helpsmilie:
I have followed these 3 references:
http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/Problem-with-SEND-Push-Notificati...
http://supportforums.blackberry.com/t5/Android-Runtime-Development/Not-receiving-push-notification-o...
But I don't get the result as expected, instead i always get ERROR CODE 2000 like this:
Our PUSH-ID: 1401179949.8267
An error has occured
Error CODE: 2000
Error DESC: 2000
string(217) " "
The string(217) " " contains:
<pap>
<badmessage-response bad-message-fragment="2000" desc="2000" code="2000"></badmessage-response>
</pap>
The code I use:
$appid = '4746-6135ee38Dm11ro8094c98i7900xxxxxxxxx';
$password = 'xxxxxxxx';
$boundary = "mPsbVQo0a68eIL3OAxnm";
$deliverbefore = gmdate('Y-m-d\TH:i:s\Z', strtotime('+2 minutes'));
//An array of address must be in PIN format or "push_all"
$addresses = '';
foreach ($registatoin_ids as $value) {
$addresses .= '<address address-value=' . $value . '/>';
}
// Open connection
$ch = curl_init();
$err = false;
$messageid = microtime(true);
$data =
'--' . $boundary . "\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" .
'--' . $boundary . "\r\n" .
// 'Content-Encoding: binary' . "\r\n" .
'Content-Type: text/plain' . "\r\n" .
'Push-Message-ID: ' . $messageid . "\r\n\r\n" .
'{
"key":"value",
"key2":"value2"
}'. "\r\n" .
'--' . $boundary . '--' . "\n\r";
$url = 'https://cp4746.pushapi.eval.blackberry.com/mss/PD_pushRequest';
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_USERAGENT, "SAA push application");
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_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: multipart/related; boundary=" . $boundary . "; type=application/xml", "Accept: text/html", "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";
echo '<pre>' . $xmldata . '</pre>' . "\n";
var_dump($xmldata);
}
var_dump($vals);
return $xmldata;
where registration id i get is already in correct form without prefix, what did I do wrong?