我有一个简单的python函数,在这里,我只需要从公共主题中获取输入,然后打印出来。
import base64,json
def hello_pubsub(event, context):
"""Triggered from a message on a Cloud Pub/Sub topic.
Args:
event (dict): Event payload.
context (google.cloud.functions.Context): Metadata for the event.
"&
我正在尝试谷歌物联网和谷歌PubSub。我正在将MQTT消息从设备发送到我所订阅的pubsub队列(我将其称为“服务器”)。在google云控制台中,我更新了设备设置,并在设备中获得了设置消息。
google tutorial中的一切都运行得很好,但我想知道是否有可能以另一种方式设置消息传递:即“服务器”发送消息到设备使用MQTT订阅的pubsub队列。
末尾的模式让我认为只有"config“mqtt队列(/devices/XXXX/config)可以这样使用。
我需要的是从“服务器”到“设备”的一对一通信,恐怕唯一的方法就是使用配置
基于官方
我尝试使用"PubSub拉订阅“触发器创建一个云函数。
import base64
def hello_pubsub(event, context):
"""Triggered from a message on a Cloud Pub/Sub topic.
Args:
event (dict): Event payload.
context (google.cloud.functions.Context): Metadata for the event.
"""
我正在尝试设置gmail.users.watch,但得到了一个403个错误:
Error sending test message to Cloud PubSub projects/project-id/topics/topic-id : User not authorized to perform this action.
身份验证使用的是GOOGLE_APPLICATION_CREDENTIALS方法和下载的凭据json文件。
以下代码工作正常,这支持了我的假设,即身份验证通常是有效的:
const pubsub = PubSub();
const topic = pubsub.topic
我正在尝试使用PHP创建一个发布/订阅通知。我有一个项目和一个服务帐户。我的代码看起来像这样: use Google\Cloud\Core\Iam\PolicyBuilder;
use Google\Cloud\PubSub\PubSubClient;
use Google\Cloud\Storage\StorageClient;
self::$storage_client = new StorageClient(
[
'projectId' => "MY PROJ