現在phpのコードからcurlを利用してループ処理でandroidへプッシュ通知を出しているのですがこれを一括で行う方法はありますか?
php
1 $headers = [ 2 "Authorization: key=".$apiKey, 3 "Content-Type: application/json" 4 ]; 5 $messageAr = ["A","B","C"]; 6 7/** 8*ループではなく一括で送信したい 9**/ 10 11 foreach($messageAr as $value){ 12 $fields = [ 13 "registration_ids" => is_array($pushTokens) ? $pushTokens : [$pushTokens], 14 "notification" => [ 15 "text" => $value 16 ] 17 ]; 18 19 $handle = curl_init(); 20 curl_setopt($handle, CURLOPT_URL, "https://fcm.googleapis.com/fcm/send"); 21 curl_setopt($handle, CURLOPT_POST, true); 22 curl_setopt($handle, CURLOPT_HTTPHEADER, $headers); 23 curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); 24 curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false); 25 curl_setopt($handle, CURLOPT_POSTFIELDS, json_encode($fields)); 26 $result = curl_exec($handle); 27 curl_close($handle); 28 }
あなたの回答
tips
プレビュー