相关疑难解决方法(0)

Firebase 云消息传递 HTTP V1 API:如何通过 REST 调用获取 Auth 2.0 访问令牌?

为了将HTTP V1 API(而不是旧版 API)与 PHP 一起使用,必须使用 REST 接口。

https://firebase.google.com/docs/cloud-messaging/send-message#top_of_page

我想知道如何获取 Auth 2.0 访问令牌?

https://firebase.google.com/docs/cloud-messaging/auth-server

由于 PHP 没有Google API Client Library(请参阅上面链接中的示例),如何通过 REST 调用接收 Auth 2.0 令牌(无需显示 PHP 代码)?

相关问题:一旦收到这个短暂的令牌,如何刷新这个令牌?工作流程是怎样的?

多谢!

php rest firebase firebase-cloud-messaging

7
推荐指数
2
解决办法
5147
查看次数

如何在 php 中使用 FCM HTTP v1 API

我已经将 FCM 与旧协议一起使用,但找不到任何具体的文档来将新的 FCM HTTP v1 API 与 php 结合使用。

我已设法将Google API 客户端库导入到我的项目中,但找不到有关如何获取 fcm 消息所需范围的访问令牌的任何文档或教程。

php firebase firebase-cloud-messaging

7
推荐指数
3
解决办法
5718
查看次数

为 Firebase 云消息传递 PHP 生成 OAUTH 令牌

我有一个 PHP 页面,我用它来向我开发的移动应用程序的用户发送通知,该页面直到上个月都工作正常,然后它给了我这个错误

{"multicast_id":5174063503598899354,"成功":0,"失败":1,"canonical_ids":0,"结果":[{"错误":"无效注册"}]}

我尝试使用此链接中的文档生成 OAUTH 令牌 https://firebase.google.com/docs/cloud-messaging/auth-server#node.js 但它需要 NODE.JS 服务器,而我的服务器不支持 Node .Js,我尝试使用 Firebase Admin SDK 但找不到任何内容。这是页面的PHP代码

<?php

//Includes the file that contains your project's unique server key from the Firebase Console.
require_once("serverKeyInfo.php");

//Sets the serverKey variable to the googleServerKey variable in the serverKeyInfo.php script.
$serverKey = $googleServerKey;

//URL that we will send our message to for it to be processed by Firebase.
    $url = "https://fcm.googleapis.com/fcm/send";

//Recipient of the message. This can be a device token (to send to an …
Run Code Online (Sandbox Code Playgroud)

php oauth token firebase firebase-cloud-messaging

7
推荐指数
3
解决办法
7770
查看次数

使用 v1 API 中的 cURL 将 Push FCM 发送到多个设备

我需要将 FCM 推送通知发送到多个设备。我不能为此使用“主题”,因为我需要将其发送到特定的和多个令牌。

在旧方法中,我使用“register_ids”来实现此目的,但 Google 在 2023 年 6 月 20 日宣布,旧方法将于 2024 年 6 月 20 日结束。在新的 v1 API 中,不再支持“register_ids”。

我需要的是一个使用 cURL 和 PHP 向多个令牌发送推送通知的解决方案。

在这个网站上,有人问了和我类似的问题:

FCM 批量消息 URL

@Frank van Puffelen 说:

在这个新的版本化 API 中,您可以通过向常规端点发送多部分请求来发送多条消息。此过程在有关发送批量消息的部分中有完整记录,并且大多数可用的管理 SDK 也支持该过程.

Frank von Puffelen 提供了一个链接:

https://firebase.google.com/docs/cloud-messaging/send-message#send-a-batch-of-messages

然而,现在该网站上有一条说明:

本节中描述的批量发送方法已于 2023 年 6 月 21 日弃用,并将于 2024 年 6 月删除。相反,请通过实现您自己的批量发送逻辑、迭代收件人列表发送到每个收件人的令牌。对于 Admin SDK 方法,请确保更新到下一个主要版本。

在该网站的更上方,有一个标题为“向多个设备发送消息”的部分。但是,本节仅提供 Node.js、Java、Python、Go、C# 和 REST 的解决方案。我需要 PHP 和 cURL 的解决方案。

到目前为止我已经尝试过如下,但由于架构错误而无法正常工作:

$tokens = array(
"token 1", …
Run Code Online (Sandbox Code Playgroud)

curl firebase firebase-cloud-messaging

5
推荐指数
1
解决办法
3719
查看次数

标签 统计

firebase ×4

firebase-cloud-messaging ×4

php ×3

curl ×1

oauth ×1

rest ×1

token ×1