philbone / twittersearch
A package for Twitter search API.
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:package
Requires
- guzzlehttp/guzzle: ^6.2
This package is not auto-updated.
Last update: 2024-09-29 06:14:17 UTC
README
Switter is a package for Twitter search API.
Index
Requirements
- PHP 7.1 or higer.
- Guzzle PHP HTTP client.
- Twitter API Keys from Twitter Apps
Installation
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
How to use
- Import definition.
- Make a new object from Search class.
- Set token with your API keys.
- Set some value to search.
- Search the value.
Example:
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".
How to run Test SearchTest.php
Assuming that PHPUnit was installed as a dependency, simply open the terminal from the directory where Switter is installed and run it:
$ phpunit