Last active
July 28, 2017 21:41
-
-
Save kurybr/d81ed434fcd9975f85e11819d3bb16e9 to your computer and use it in GitHub Desktop.
Help to Bug Push Notification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function push_notification($index){ | |
$url = 'https://fcm.googleapis.com/fcm/send'; | |
$fields = array ( | |
"to" => "", | |
"priority" => "normal", | |
"collapse_key" => "Campaing News", | |
"content_available"=> true, | |
"content-available" => 1, | |
"restricted_package_name" => "", | |
'data' => array ( | |
"code" => 1 | |
), | |
"notification" => array( | |
"title" => "Vitrine", | |
"body" => "great match! 1" . $index, | |
"sound" => "default", | |
"image" => "www/assets/icon/icon.png", | |
"actions" => array( | |
array( | |
"icon" => "emailGuests", | |
"title" => "EMAIL GUESTS", | |
"callback" => "app.emailGuests", | |
"foreground" => true | |
), | |
array( | |
"icon" => "snooze", | |
"title" => "SNOOZE", | |
"callback" => "app.snooze", | |
"foreground" => false | |
) | |
) | |
) | |
); | |
$fields = json_encode ( $fields ); | |
$headers = array ( | |
'Authorization: key=' . "", //firebase server key | |
'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 ); | |
var_dump($result); | |
curl_close ( $ch ); | |
} | |
for ($i=0; $i < 5; $i++) { | |
push_notification($i); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment