Php Laravel排队并发布到Facebook

Php Laravel排队并发布到Facebook,php,twitter,laravel-5,Php,Twitter,Laravel 5,我正试图使用幼虫的队列发布到Facebook,我没有运气!我的代码在不使用队列的情况下运行良好,但我需要能够将相同的代码用于que 我在failed jobs表中遇到此异常: exception 'Exception' with message '[220] Your credentials do not allow access to this resource.' in /home/vagrant/sites/pms/vendor/thujohn/twitter/src/Thujohn/Tw

我正试图使用幼虫的队列发布到Facebook,我没有运气!我的代码在不使用队列的情况下运行良好,但我需要能够将相同的代码用于que

我在failed jobs表中遇到此异常:

exception 'Exception' with message '[220] Your credentials do not allow access to this resource.' in /home/vagrant/sites/pms/vendor/thujohn/twitter/src/Thujohn/Twitter/Twitter.php:297
我将图像发布到Facebook的初始代码如下所示:

try {
    $fb->setDefaultAccessToken($token);
    $fb->post('/me/photos', [
         'url' => cloudinary_url("$photorequest"),
         'caption' => $body . $userPage
    ]);
} catch (Facebook\Exceptions\FacebookResponseException $e) {
    // continue to next request;
}
现在,当我尝试使用que时,我在我的jobs文件夹中执行了以下操作:

namespace PMS\Jobs;

use PMS\Jobs\Job;
use Illuminate\Http\Request;
use SammyK\LaravelFacebookSdk\LaravelFacebookSdk;
use Facebook;
use Session;
use PMS\Photo;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class PostToFBwithImage extends Job implements ShouldQueue {
    use InteractsWithQueue, SerializesModels;

    public $fb;
    public $token;
    public $photorequest;
    public $userPage;
    public $body;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($token, $photorequest, $userPage, $body) {
        $this->token = $token;
        $this->photorequest = $photorequest;
        $this->userPage = $userPage;
        $this->body = $body;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle(LaravelFacebookSdk $fb) {
        try {
            $fb->setDefaultAccessToken($token);
            $fb->post('/me/photos', [
                'url' => cloudinary_url("$photorequest"),
                'caption' => $body . $userPage
            ]);
        } catch (Facebook\Exceptions\FacebookResponseException $e) {
            // continue to next request;
        }
    }
}
在我的控制器中调用:

$this->dispatch(new PostToFBwithImage($token, $photorequest, $userPage, $body));
我知道我在我的PostToFBwithImage课程中做错了什么,我只是不知道是什么?

这不应该吗

$fb->setDefaultAccessToken($token);
$fb->post('/me/photos', ['url' => cloudinary_url("$photorequest"),'caption' => $body . $userPage]);
是这个吗

$fb->setDefaultAccessToken($this->token);
$fb->post('/me/photos', ['url' => cloudinary_url($this->photorequest), 'caption' => $this->body . $this->userPage]);
?


另外,您确定在创建作业时向构造函数传递了正确的值吗?

您使用的是什么队列驱动程序?这个代码以什么方式不起作用?你有什么错误吗?