PHP code example of mineur / twitter-stream-api-bundle
1. Go to this page and download the library: Download mineur/twitter-stream-api-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mineur / twitter-stream-api-bundle example snippets
composer
// app/AppKernel.php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
// ...
new Mineur\TwitterStreamApiBundle\TwitterStreamApiBundle(),
];
}
}
// Controllers/DemoController.php
class DemoCommand extends ContainerAwareCommand
{
protected function configure()
{
//...
}
public function execute(InputInterface $input, OutputInterface $output)
{
/** @var PublicStream $publicStream */
$publicStream = $this
->getContainer()
->get('twitter_stream_api_consumer');
$publicStream
->listenFor([
'your',
'keywords',
'list'
])
->setLanguage('es')
->do(function(Tweet $tweet) {
// you can do whatever you want with this output
// prompt it, enqueue it, persist it into a database ...
$output->writeln($tweet);
});
}
}