我使用以下方法将对象添加到 Firebase 数据库。
$url = "https://myfb.firebaseio.com/api/types/ty/packs.json";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $userData);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
$jsonResponse = curl_exec($ch);
if(curl_errno($ch))
{
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
The $userData
will be kept under uniquely generated node in our database as follows.
我想将我的自定义密钥提供给该节点。我如何做到这一点?
如果您使用 Firebase REST API 使用自定义 ID 在 Firebase 中插入数据且没有任何子(自动生成)ID,请使用“Put”而不是“Post”。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)