| 1 |
www |
1 |
<?php
|
|
|
2 |
header('Content-type: text/plain');
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
$auth_key = 'AAAASl-WiJg:APA91bEJztKaM1MtToQcmhPlSYY6m6t3ciYuGcKgpOWkxAVfqWgEBns1pPYCkGMUyBsT3WSHbBRNHFNz_GsjZKVdHiU8yqv_Lk4LckFLheBU6wPrk_nhDugbPTi_nTXPkMNTXGLuFKAT';
|
|
|
8 |
|
| 646 |
efrain |
9 |
$token = 'cc4zrdtegkS7s-g3Iovw4n:APA91bEFf96mODSNraSc3Hs_DUv4SbNCn4DWMV6WkzzJrSS7K4jpkg3T-XU1Pqqc2spI1EL7xn4hxgUNJUT1fLijGCYULUymkkeoc8gKjCZX42PeoL8v9ThA4nBLY4K0VqEYqgGg0Dpb';
|
| 1 |
www |
10 |
|
|
|
11 |
$fields = [
|
|
|
12 |
'registration_ids' => [
|
| 112 |
efrain |
13 |
$token,
|
| 1 |
www |
14 |
],
|
| 646 |
efrain |
15 |
'notification' => [
|
| 630 |
efrain |
16 |
'body' => 'Envio de mensaje de prueba #4',
|
|
|
17 |
'title' => 'Logeo en otro dispositivo',
|
| 1 |
www |
18 |
'vibrate' => 1,
|
|
|
19 |
'sound' => 1
|
| 646 |
efrain |
20 |
],
|
| 1 |
www |
21 |
|
|
|
22 |
'content_available'=> true,
|
| 646 |
efrain |
23 |
/*'data' => [
|
| 1 |
www |
24 |
'command' => 'signout'
|
| 646 |
efrain |
25 |
]*/
|
| 1 |
www |
26 |
];
|
|
|
27 |
|
|
|
28 |
print_r($fields);
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
$headers = [
|
|
|
32 |
'Authorization: key=' . $auth_key,
|
|
|
33 |
'Content-Type: application/json'
|
|
|
34 |
];
|
|
|
35 |
|
|
|
36 |
print_r($headers);
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
$ch = curl_init();
|
|
|
40 |
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
|
|
|
41 |
curl_setopt( $ch,CURLOPT_POST, true );
|
|
|
42 |
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
|
|
|
43 |
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
|
|
|
44 |
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
|
|
|
45 |
curl_setopt( $ch,CURLOPT_VERBOSE, true );
|
|
|
46 |
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
|
|
|
47 |
$result = curl_exec($ch);
|
|
|
48 |
$err = curl_error($ch);
|
|
|
49 |
|
|
|
50 |
if ($err) {
|
|
|
51 |
die('FCM Send Error: ' . $err);
|
|
|
52 |
}
|
|
|
53 |
curl_close( $ch );
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
print_r($result);
|