Jump to content

Firebase create Topic


techker

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
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"}"

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.