Trying to retrieve data from firebase, but getting error. Please help me for setup this.
My Code is
function Process($url){
$Return = new stdClass;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0); // remove header
curl_setopt($ch, CURLOPT_NOBODY, 0); // remove body
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
if($Return->response = curl_exec($ch)){
$Return->response = json_decode($Return->response);
}
$Return->httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$Return->curl_errno = curl_errno($ch);
$Return->curl_error = curl_error($ch);
curl_close($ch);
return $Return;
}
$Info = Process('https://project-id.firebaseio.com/users/jack/name.json');
but getting response Unauthorized request.
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));add this