Php 如何在作业队列中传递curl资源?
如何在作业队列中传递curl资源?但现在curl不支持队列,不支持响应 在这里输入代码Php 如何在作业队列中传递curl资源?,php,laravel,laravel-queue,laravel-jobs,Php,Laravel,Laravel Queue,Laravel Jobs,如何在作业队列中传递curl资源?但现在curl不支持队列,不支持响应 在这里输入代码 $fields = json_encode($fields); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://onesignal.com/api/v1/notifications'); curl_setopt($ch, CURLOPT_HTTPHEADER, ['
$fields = json_encode($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://onesignal.com/api/v1/notifications');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json; charset=utf-8']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
我也用过拉威尔·古泽尔(laravel Guzzle)
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://onesignal.com/api/v1/notifications', [
'json' => $fields
]);
传递什么到队列作业?我必须为mobile发送一个通知,所以我要用上面提到的curl在队列作业上添加通知,curl在使用命令php artisan queue:listeni时不在作业中工作我不理解“传递”资源部分,您将什么资源传递到哪里?我刚刚创建了一个作业页面OneSignalJobs,名为curl init,并在运行后传递数组数据(json)队列不工作curl,这是我的问题运行时curl在作业页面不工作,php artisan队列:侦听
class OneSignalJobs implements ShouldQueue
{ public function handle()
{ $files=[]
$fields = json_encode($fields);
$url = "https://onesignal.com/api/v1/notifications";
$response = $client->createRequest("POST", $url, $fields);
$response = $client->send($response);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://onesignal.com/api/v1/notifications');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json; charset=utf-8']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $files);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch); }