philbone/twittersearch

A package for Twitter search API.

dev-master 2018-05-21 18:57 UTC

This package is not auto-updated.

Last update: 2024-09-29 06:14:17 UTC


README

Build Status

Switter is a package for Twitter search API.

Index

  1. Requirements
  2. Installation
  3. How to use
    1. Example
  4. Running a Test

Requirements

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