Switter is a package for Twitter search API.
- PHP 7.1 or higer.
- Guzzle PHP HTTP client.
- Twitter API Keys from Twitter Apps
Clone repository from GitHub
$ git clone https://github.com/philbone/twittersearch.git switter
Inside the directory where Switter is installed, open the terminal and run "composer install" to get the dependencies.
$ composer install
- Import definition.
- Make a new object from Search class.
- Set token with your API keys.
- Set some value to search.
- Search the value.
use Twitter\Search\Search;
$apiKey = "jLl8hRLXY3xEPHGnx7UndxrcV"; // replace with your own api key.
$apiSecret = "8erBjpOra7GCGkHOK3YbTcqoKTQBSyKgljgG4MCDZi5cKRb7op"; // replace with your own api secret.
$search = new Search();
$search->setToken($apiKey, $apiSecret);
$value = ["q" => "#PHP #Composer"];
$response = $search->search($value);
var_dump($response);
A detailed test example can be found in test/SearchTest.php. Pay special attention to the sample method "testSuccessSearch".
Assuming that PHPUnit was installed as a dependency, simply open the terminal from the directory where Switter is installed and run it:
$ phpunit