Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用twitterapi的Laravel队列_Php_Twitter_Queue_Laravel 5.2_Twitter Oauth - Fatal编程技术网

Php 使用twitterapi的Laravel队列

Php 使用twitterapi的Laravel队列,php,twitter,queue,laravel-5.2,twitter-oauth,Php,Twitter,Queue,Laravel 5.2,Twitter Oauth,我正在使用上的thujohn/twitter包将用户状态帖子从我的站点更新到twitter 我想使用用户的队列在后台发布此函数。但我一直得到一份失败的工作。有一个错误: exception 'Exception' with message '[220] Your credentials do not allow access to this resource.' in /home/vagrant/sites/pms/vendor/thujohn/twitter/src/Thujohn/Twitt

我正在使用上的thujohn/twitter包将用户状态帖子从我的站点更新到twitter

我想使用用户的队列在后台发布此函数。但我一直得到一份失败的工作。有一个错误:

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));
在我的控制器中,我这样调度:

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));

如果我在控制器中运行我的函数,它可以正常工作,但如果我尝试将其分派到作业,作业会失败

我通过切换到其他库来解决此问题,如下博客文章: