Jump to content

Recommended Posts

Hey guy's im messing around with firebase for the first time..I got 

Send message is working

retreive Tokens all good

But im stuck on creating Topics for individual notifications..

 

i started in CURL ,Tried in postman and it works but to add it in php is a different story..What happens is i don't get the response.or any indications that it worked?

$authToken = 'key=xxxxxxxxxxx-4-vd8IyE5Zg0D1tlAhLokD1vuZpUWODUSnZAPaVXYTBbEnqedNsHvAJdDwy2cVU9Si8MKNQ78SrNYMaA1vaX';
$project_id='246202749xxxxx';
$data = array(
'operation' => 'create',
'notification_key_name' => 'appUser-2xxxxxx',
'registration_ids' =>  'dBkCkjbIGVg:APA91bHTzf5rQHEtLjAv_THs1Kv_KK0uHVj85nC6Qy39CtY3Xke_M2p4YxRLGKloFpuDraWRd5jSGEMMD8N2x3ROlajdSB_7FGnxWnP2K-HNQ-up1Rxxxxxxxxxxx'

);

$data_string = json_encode($data);

$ch = curl_init('https://android.googleapis.com/gcm/notification');

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'project_id:'.$project_id,
    'Authorization: '.$authToken,
    'Content-Length: ' . strlen($data_string)));



if($result === FALSE){
   die('Error');
}

return $result;

$result = curl_exec($ch);

$responseInfo = curl_getinfo($result);

$httpResponseCode = $responseInfo['http_code'];

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/307363-firebase-create-topic/
Share on other sites

man..that was a simple fix..lol seen the error was my appid...

how can i store the results in my db?

 

i need to parse the json?

string(142) "{"notification_key":"APA91bG-LwsEDQynKWH1bPPf5FQJL2D9R4Oi8XXXXXXXbJ4TebsJqRSRgRfwIey96BnDZEszWxk-6ne8bMgVA1KteNNle5WBZCndj2Y0w"}"

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.