Advertisement
rusday14

Firebase Sukses Notifikasi

Nov 9th, 2021
1,048
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.29 KB | None | 0 0
  1. define( 'API_ACCESS_KEY', 'AAAAVczb0aU:APA91bGdQ53zXBr8BhxvennbNPWI_Vg_5GLgxSYcFqqb2ssq_2Kx7s3ZT3VH3OXMvvJ84GZ-metjgm4VDlFX5c2Te5HXuaBQuGGU6bPdI5xh10mb1fWzj3U7BvK95ilEcAvY-5j_owI1' );
  2.                    
  3.                         $merchant_idxx                  = $dataxxrr['merchant_id'];
  4.                         $OrderCode                      = $sales_order_code;
  5.                         $InvoiceCode                    = $sales_invoice_code;
  6.                        
  7.                        
  8.                         $checkDataxx            = "SELECT merchant_name FROM public.merchant
  9.                                                     WHERE merchant_id='".$merchant_idxx."'";
  10.                         $chckDtaxx              = pg_query($conn, $checkDataxx);
  11.                         $chkrdtaxxx             = pg_fetch_assoc($chckDtaxx);
  12.                        
  13.                        
  14.                        
  15.                         $pesanx             = "<font color='black'><b>".$chkrdtaxxx['merchant_name']."</b></font>​";
  16.                         $totBiayaxrs        = "<font color='black'><b>".rupiah($tot_biaya_all)."</b></font>​";
  17.                         $checkData          = "SELECT fcm_data_fcmid FROM public.fcm_data
  18.                                                WHERE fcm_data_account_id ='".$account_id."'
  19.                                                AND fcm_data_notif_pembelian='1'";
  20.                         $chckDta            = pg_query($conn, $checkData);
  21.                        
  22.                         // echo $checkData;exit;
  23.                         while($chkrdta          = pg_fetch_assoc($chckDta)){
  24.                            
  25.                                 $fcmid              = $chkrdta['fcm_data_fcmid'];
  26.                                 $registrationIds    = array($fcmid);
  27.                            
  28.                                 $msg = array
  29.                                 (
  30.                                     "code"      =>"1",
  31.                                     "message"   => "",
  32.                                     "title"     => "Pesanan Selesai",
  33.                                     "subtitle"  => "Pesanan dengan Invoice ID ".$InvoiceCode." Telah Selesai, Dana Sebesar ".$totBiayaxrs." Akan Otomatis Kami Teruskan ke ".$pesanx." dalam waktu Maksimal 1x24 Jam, Terimakasih",
  34.                                     "tickerText"=> "",
  35.                                     "vibrate"   => 1,
  36.                                     "sound"     => 1,
  37.                                     "largeIcon" => "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png",
  38.                                     "smallIcon" => "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png",
  39.                                     "profile_pic" => "",
  40.                                     "notification_icon" =>"https://www.pngfind.com/pngs/m/533-5335061_sacola-icon-icons-bolsa-compras-bag-bags-freetoedit.png",
  41.                                     "jenis"         =>"1.6",
  42.                                     "OrderCode"     =>"".$OrderCode."",
  43.                                     "InvoiceCode"   =>"".$InvoiceCode.""
  44.                                    
  45.                                 );
  46.  
  47.                                 $fields = array
  48.                                 (
  49.                                     'registration_ids'  => $registrationIds,
  50.                                     'data'              => $msg
  51.                                 );
  52.  
  53.                                 $headers = array
  54.                                 (
  55.                                     'Authorization: key=AAAAVczb0aU:APA91bGdQ53zXBr8BhxvennbNPWI_Vg_5GLgxSYcFqqb2ssq_2Kx7s3ZT3VH3OXMvvJ84GZ-metjgm4VDlFX5c2Te5HXuaBQuGGU6bPdI5xh10mb1fWzj3U7BvK95ilEcAvY-5j_owI1',
  56.                                     'Content-Type: application/json'
  57.                                 );
  58.  
  59.                                 $ch = curl_init();
  60.                                 curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
  61.                                 curl_setopt( $ch,CURLOPT_POST, true );
  62.                                 curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
  63.                                 curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
  64.                                 curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
  65.                                 curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
  66.                                 $resultxx = curl_exec($ch );
  67.                                 curl_close( $ch );
  68.                                 $data_id    = json_decode($resultxx, true);
  69.                                
  70.                                 $filename   = "log_SendPesananSelesai.log";
  71.                                 $fh         = fopen($filename, "a");
  72.                                 $content    = "\r\n" .date("Y-m-d H:i:s")."\r\n ( ISI QUERY = ".$checkData." )";
  73.                                 fwrite($fh, $content);
  74.                                 fclose($fh);
  75.                         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement