How to post data to Firebase with a curl command using PHP
A very simply google search for your exact question lead me to a Stack Overflow post How to post data to firebase using PHP? with a solution.
Solution is:
- = '{"id": "6"}';
- = "https://test.firebaseio.com/test_api/types.json";
- = curl_init();
- curl_setopt(, CURLOPT_URL, );
- curl_setopt(, CURLOPT_RETURNTRANSFER, true);
- curl_setopt(, CURLOPT_POST, 1);
- curl_setopt(, CURLOPT_POSTFIELDS, );
- curl_setopt(, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
- = curl_exec();
- if(curl_errno())
- {
- echo 'Curl error: ' . curl_error();
- }
- curl_close();
Firebase accept json object and you have to post as json object. E puoi usare Content-Type: application/x-www-form-urlencoded o Content-Type: text/plain
Il merito della risposta va all'utente isuru su Stack Overflow.