2
我想用幼蟲的隊列發佈到Facebook,我沒有運氣!我的代碼工作正常,不用隊列,但我需要能夠使用相同的代碼與一個隊列。Laravel隊列併發布到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;
}
我試圖用一個:
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的圖像看起來是這樣的闕,我做這在我的工作文件夾:
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類中做錯了什麼,我只是不知道是什麼?
你在使用什麼隊列驅動程序?這種代碼不工作的方式是什麼?你有什麼錯誤嗎? – Aron