function push_notifications_c2dm_token in Push Notifications 7
Determine the auth string from C2DM server.
1 call to push_notifications_c2dm_token()
- push_notifications_c2dm_send_message in ./
push_notifications.module - Send out push notifications through C2DM.
File
- ./
push_notifications.module, line 751 - Push Notifications functionality.
Code
function push_notifications_c2dm_token() {
$data = array(
'Email' => PUSH_NOTIFICATIONS_C2DM_USERNAME,
'Passwd' => PUSH_NOTIFICATIONS_C2DM_PASSWORD,
'accountType' => 'HOSTED_OR_GOOGLE',
'source' => 'Company-AppName-Version',
'service' => 'ac2dm',
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, PUSH_NOTIFICATIONS_C2DM_CLIENT_LOGIN_ACTION_URL);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl);
curl_close($curl);
// Get the auth token.
preg_match("/Auth=([a-z0-9_\\-]+)/i", $response, $matches);
$auth_token = $matches[1];
if (!$auth_token) {
watchdog('push_notifications', 'Google C2DM Server did not provide an authentication token.', NULL, WATCHDOG_ERROR);
}
else {
return $auth_token;
}
}