I've an programm that retreive favorites that belong to specific user. when I run php artisan twitter:listen-for-hash-tags commented function it's works in hashtag but when userStream I've an error [ErrorException] Undefined index: event
command code
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use TwitterStreamingApi;
class ListenForHashTags extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'twitter:listen-for-hash-tags';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Listen for hashtags being used on Twitter';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//TwitterStreamingApi::publicStream()
//->whenHears('#laravel', function (array $tweet) {
// dump("{$tweet['user']['screen_name']} tweeted by {$tweet['text']}");
//})
// ->startListening();
TwitterStreamingApi::userStream()
->onEvent(function(array $event) {
if ($event['event'] === "favorite by {$event['source']['screen_name']}") {
dump("Our tweet {$event['target_object']['text']} got favorited by {$event['source']['screen_name']}");
}
})
->startListening();
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire