在執行php artisan queue:work的時候不斷的出現
[2017-09-07 17:52:20] Processing: App\Jobs\MyJob
以下是MyJob.php的內容
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class MyJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private $acc_token;
private $sender;
private $answer;
private $file_type;
private $file_url;
private $response;
private $ch;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($acc_token, $sender, $answer, $file_type, $file_url)
{
$this->acc_token = $acc_token;
$this->sender = $sender;
$this->answer = $answer;
$this->file_type = $file_type;
$this->file_url = $file_url;
}
/**
* Execute the job.
*
* @return void
*/
public function handle($response, $ch)
{
$response = [
'recipient' => [ 'id' => $this->sender ],
'message' => [ 'text' => $this->answer ],
];
$ch = curl_init('https://graph.facebook.com/v2.10/me/messages?access_token='.$this->acc_token);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($response));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_exec($ch);
curl_close($ch);
}
}