使用php和firebase控制台帐户发送推送通知

to all, ehm i have this php code:

    <?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR_FIREBASE_API_ACCESS_KEY' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
(
    'body'  => $_GET['body'],
    'title'     => $_GET['title'],
    'vibrate'   => 1,
    'sound'     => 1,
);
$fields = array
(
    'registration_ids'  => $registrationIds,
    'notification'          => $msg
);

$headers = array
(
    'Authorization: key=' . API_ACCESS_KEY,
    'Content-Type: application/json'
);

$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );
echo $result;
?>

I've just searched but what i would want is:

1) Which is the YOUR_FIREBASE_API_ACCESS_KEY? In settings of my app in firebase i see SERVER KEY, PREVIOUS SERVER KEY (translated from italian) and SENDER ID.

2) How can i get registration ids from firebase account app? If i want send push notification to all device that have installed this app how can i DO it?

3) When button clicked:

  • Connect to firebase account throught API key (Which is?)
  • Send to all devices that have my app installed (topic or not?)

Please, help me. I'm confused.

More than clear of that i can't.

Thanks Davide

dongtan6336
dongtan6336 :):):):)
大约 2 年之前 回复
dongzhao2725
dongzhao2725 不,但我爱意大利:)
大约 2 年之前 回复
drelgkxl93433
drelgkxl93433 你是意大利人吗?
大约 2 年之前 回复
doukao1925
doukao1925 我恭喜“大家好”,但有些不对劲......
大约 2 年之前 回复
duanbeng1923
duanbeng1923 对不起,但您的问题不明确...可以添加更多说明
大约 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问