techker Posted June 9, 2018 Share Posted June 9, 2018 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 More sharing options...
NotionCommotion Posted June 10, 2018 Share Posted June 10, 2018 Remove or relocate these two lines and you should be good. if($result === FALSE){ die('Error'); } return $result; Link to comment Share on other sites More sharing options...
techker Posted June 11, 2018 Author Share Posted June 11, 2018 Even by removing the 2 line i get no text to show? in the console in fidler i see i get a 200 back thats ok but no response output to show the topic key.. Link to comment Share on other sites More sharing options...
gizmola Posted June 11, 2018 Share Posted June 11, 2018 The last line of the script should output the result if you want to see anything. var_dump($result); Link to comment Share on other sites More sharing options...
techker Posted June 11, 2018 Author Share Posted June 11, 2018 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 More sharing options...
Barand Posted June 11, 2018 Share Posted June 11, 2018 http://lmgtfy.com/?q=php+json Link to comment Share on other sites More sharing options...
gizmola Posted June 11, 2018 Share Posted June 11, 2018 PHP has a nice function for you: json_decode(). Read the manual page for it! There is an option to either convert it to object format or an array. Use which ever form suits you. Link to comment Share on other sites More sharing options...
techker Posted June 13, 2018 Author Share Posted June 13, 2018 will do!!Thx Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.