B4J Question how to convert php to b4j?


Active Member
Licensed User
This code works to send messages to firebase, how can i convert it to b4j?


$descrizione="NEWS id 1";


$headers= array(
"Authorization:  key=AAAAVeez71A:APA91bF0_9w25.........................................,
"Content-Type: application/json"
$message= array(
       "title"=> $title,
$jfields = json_encode($message);

//echo $jfields;   

        // create curl resource
        $ch = curl_init();

        // set url
        curl_setopt($ch, CURLOPT_URL, $url);

        //return the transfer as a string
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $jfields);
        //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        // $output contains the output string
        $output = curl_exec($ch);
if($output===FALSE) {
    echo "Errore invio dati". curl_error($ch);
} else {
    echo "Ok invio effettuato";
        // close curl resource to free up system resources