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));
我功能工作正常,如果我在我的控制器中运行它,但如果我尝试派遣它到一份工作,我的工作失败