gpt4 book ai didi

php - Firebase PHP 数据提交 - arrayValue, mapValue

转载 作者:可可西里 更新时间:2023-11-01 00:54:16 24 4
gpt4 key购买 nike

我正在尝试使用 PHP 和 Google api 将数据推送到 firestore 数据库。

在我在网络上看到的文档和示例中,我可以在发送数据时使用 mapValuearrayValue

我使用的例子如下:-

[
"orderName" => [
"stringValue" => "Gbeila Aliu Wahab"
],
"orderLocationName" => [
"stringValue" => "Accra Mall Limited"
],
"orderTotalAmount" => [
"doubleValue" => 150.5
],
"orderDescription" => [
"stringValue" => "Lorem Ipsum is simply dummy text of the printing and typesetting industry"
],
"orderLocationGeoPoints" => [
"geoPointValue" => (object) [
"latitude" => 5.5557,
"longitude" => -0.1963
]
],
"orderStatus" => [
"stringValue" => "NotAssigned"
],
]

这工作得很好,但是当我尝试发送对象或数组时,我收到以下错误返回给我:-

"message": "Invalid JSON payload received. Unknown name \"map_value\" at 'document.fields[0].value': Proto field is not repeating, cannot start list.",

尝试使用以下代码映射值时:-

"orderName" => [
"mapValue" => ["Gbeila Aliu Wahab", 123]
]

// or

"orderName" => [
"arrayValue" => [
"first" => [
"stringValue" => "test"
],
"second" => [
"stringValue" => "test123"
]
]
]

我尝试了很多变体来尝试让它工作。

我应该如何使用 mapValuearrayValue 我可以看到很多关于 value 选项的提及,但我看不到任何关于如何使用.

如有任何帮助,我们将不胜感激。

最佳答案

根据 the documentation.,您生成的数组或 map 的有效负载不正确您需要将实际数据(存储)包装在 values 键下,您的最终数组应该是:

["orderName" => ["arrayValue" => ["values" => [["stringValue" => "test"], ["stringValue" => "test123"]]]]]

同样,您的 mapValue 应该是

["orderName" => ["mapValue" => ["fields" => ["field1" => ["stringValue" => "Gbeila Aliu Wahab"]]]]]

此外,您可以通过 this package. 与其他数据映射器一起玩

关于php - Firebase PHP 数据提交 - arrayValue, mapValue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54807757/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com