Skip to content

Commit

Permalink
Added php example using google's Firebase endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ani Sinanaj committed Jan 10, 2017
1 parent f6aed79 commit 37c9ce7
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions android/firebasetest
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/php
<?php
function sendGCM($message, $id) {


$url = 'https://fcm.googleapis.com/fcm/send';

$fields = array (
'registration_ids' => array (
$id
),
"data" => [
"data" => [
"alert" => "Testing " . time(),
"title" => "The title",
"vibrate" => [100,50,50,50,100],
"badge" => 1,
"tag" => "APP"
]
]
);
$fields = json_encode ( $fields );

$headers = array (
'Authorization: key=' . "<AUTH 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 );
echo $result;
curl_close ( $ch );
}

sendGCM("Test", "DEVICE TOKEN");

0 comments on commit 37c9ce7

Please sign in to comment.