finally i can send notification from android to any device install my app
but i tried that with php function i found in discussion i put it in my server
the function exected successfully but i didn't get any notify
the script i found is:
any ideas?
but i tried that with php function i found in discussion i put it in my server
the function exected successfully but i didn't get any notify
the script i found is:
and attached image tells some thing<?php
$databasehost = "xxxx";
$databasename = "xxxx";
$databaseusername ="xxxx";
$databasepassword = "xxxx";
$devicepassword="xxxx";
$serverpassword="xxxxxx";
$con = mysql_connect($databasehost,$databaseusername,$databasepassword) or die(mysql_error());
mysql_select_db($databasename) or die(mysql_error());
function sendGCM($UserID, $message) {
$query = "SELECT id From c2dm Where name='testapi'";
$res=mysql_query($query);
$row = mysql_fetch_object($res);
// Replace with real BROWSER API key from Google APIs
$apiKey = "AIzaSyBfLv6oqlvlY6e2Na4nnDs_W3rDm2s71zU"; // Browser Key
// Replace with real client registration IDs
$registrationIDs = array( $row->id );
// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
'registration_ids' => $registrationIDs,
'data' => array( "data" => $message ),
);
$headers = array(
'Authorization: key=' . $apiKey,
'Content-Type: application/json'
);
// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) );
// Execute post
$result = curl_exec($ch);
// Close connection
curl_close($ch);
echo "success"
}
sendGCM("testapi","okkkk");
?>
?>
any ideas?
Attachments
Last edited: