Insert Data to Firebase from php

1

Good colleagues I want to insert data from a small program in PHP to the Firebase Database, through Curl, I currently have this code

$url = "https://direcciones-.firebaseio.com/hola.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, "id:6");
$jsonResponse = curl_exec($ch);
if(curl_errno($ch))
{
    echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);

But at the time of Running it, the $ jsonResponse variable gives me 0, and it enters the validation of the error

What do you think could be the problem, and even try to send the complete JSON file by creating it with the Json_encode, but I get the same problem.

Greetings.

    
asked by AndreyC1995 04.01.2018 в 20:16
source

2 answers

0

If you are going to send it directly you should read how to do it from the Google API, link

    
answered by 04.01.2018 в 20:57
0

If all you want to do is insert the data, I recommend the Json form using nothing more than the apikey that gives you firebase, I have inserted some data and if you like I pass the data.

    
answered by 06.03.2018 в 21:18