2
我使用https://github.com/thujohn/twitter上的thujohn/twitter包來更新從我的網站到twitter的用戶狀態帖子。Laravel隊列與推特api
我想用幼蟲的隊列在後臺發佈這個函數。但我一直得到失敗的工作。一個錯誤:
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
堆棧跟蹤:
我的工作是這樣的:
namespace PMS\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Twitter;
use Session;
use Illuminate\Http\Request;
class PostToTwitter implements ShouldQueue
{
use InteractsWithQueue, Queueable, SerializesModels;
public $tweetLength;
public $userPage;
public $body;
//public $twitterToken;
//public $secret;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($tweetLength, $userPage, $body)
{
$this->tweetLength = $tweetLength;
$this->userpage = $userPage;
$this->body = $body;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
Twitter::postTweet(['status' => str_limit($this->body . $this->userpage,$this->tweetLength), 'format' => 'json']);
}
}
,並在我的控制,我派遣這樣的:
$this->dispatch(new PostToTwitter($tweetLength, $userPage, $body));
我功能工作正常,如果我在我的控制器中運行它,但如果我嘗試派遣它到一份工作,我的工作失敗