IAP-Push notification
public function sendGCM($message, $token,$title) {
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array (
'registration_ids' => array (
$token
),
'data' => array (
"message" => $message,"image"=>"","title"=>$title,
)
);
$fields = json_encode ( $fields );
$headers = array (
'Authorization: key=' . "AAAAEQPRwxo:APA91bFQWCTG52YN76-i9nh6g_Jlz-VUIOQEabK7jncSBuVczpiQhODGq9LqTiDkEOqweAxBqm6anknBFmRfK601cpco-Jh76pESzFqtPBx2TS7kzdf6b3mE7DVHdN_aq2swka_c5oiE",
'Content-Type: application/json'
);
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_POST, true );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $fields );
$result = curl_exec ( $ch );
// echo $result;
curl_close ( $ch );//*
}
Comments
Post a Comment