Skip to content

awelters/hatebase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hatebase API Wrapper

Simple PHP wrapper for v3.0 of the hatebase.org API

How to use

  1. Obtain a hatebase API key
  2. Install composer
  3. Create a new composer.json file with awelters/hatebase as a dependency (or add to your project's existing composer.json file)
{
    "require": {
    	"awelters/hatebase": "dev-master"
    }
}
  1. Use composer to install the dependencies
  2. Go ahead and try it out. The following php script can be used as a starting point by simply adding your Hatebase API key
<?php
/**
* Andrew's Hatebase script : Simple script to retrieve results from Hatebase API
*
* @category Awesomeness
* @date 3/03/2014
* @author Andrew Welters <awelters@hugmehugyou.org>
* @license http://opensource.org/licenses/MIT The MIT License
* @link http://www.hatebase.org/connect_api
* @link https://github.com/awelters/hatebase
*/
ini_set('display_errors', 1);
header('Content-type: application/json');

require_once __DIR__ . '/vendor/autoload.php'; // Autoload files using Composer autoload

use Hatebase\HatebaseAPI;

$settings = array(
    'key' => '',
    'version' => '3' //optional
);
$hatebase = new HatebaseAPI($settings);

//See http://www.hatebase.org/connect_api for filter options
$filters = array('about_nationality' => '1', 'language' => 'eng');
$output = 'json'; //either 'xml' or 'json', 'xml' is faster
$query_type = 'sightings'; //either 'vocabulary' or 'sightings'

try {
	$result = $hatebase->performRequest($filters, $output, $query_type);
	print_r($result);
}
catch(Exception $e) {
	echo 'Error: '.$e;
}

About

Simple PHP wrapper for v3.0 of the hatebase.org API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages