dongmijgnnq0118 2016-07-13 04:46
浏览 61

在PHP中创建JSON对象并通过Firebase推送通知发送[重复]

This question already has an answer here:

i am new to php. i am implementing Firebase push notification service in PHP .

The required json object is like

{ "data": {
    "score": "5x1",
    "time": "15:10"
  },
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..."
}

Now in firebase i have to send my data in this format but i am not sure how to make JSON object of this data and use this object in firebase .

And if I want to use Array of IDs then how this will work?

As per official firebase documentation they didn't define method to use array of ID's.

https://firebase.google.com/docs/cloud-messaging/downstream

</div>
  • 写回答

2条回答 默认 最新

  • dsce23640 2016-07-13 04:58
    关注

    Create an array in a same format that you want to sent to Firebase like bellow

    $arr = ['data'=> [
            'score'=> "5x1",
            'time'=> "15:10"
            ],
            "to" => "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..."
          ];
    

    and then use the php function json_encode(var); and it will return you the json object.

    json_encode($arr)
    

    and if i want to use Array of id then how this will work. I am not sure about this.

    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大