PHP code example of sergix44 / twscraper
1. Go to this page and download the library: Download sergix44/twscraper 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/ */
sergix44 / twscraper example snippets
use SergiX44\Twitter\TwitterScraper;
$scraper = TwitterScraper::make()
->search('near:Verona within:2km filter:images filter:hashtags', new DateTime('2019-06-15'), new DateTime('2019-07-22'))
->setLang('en')// optional
/** @var Tweet[] $tweets */
->onChunk(function (array $tweets, int $totalTweets) { // optional
//...
}, true) // than flush? (useflul when processing lot of tweets and avoid memory exhausted errors)
->setChunkSize(100)// optional
->run();
/** @var Tweet[] $tweets */
$tweets = $scraper->getTweets();