Padgett / php-restclient

A generic REST API client for PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP REST Client

(c) 2011 Travis Dent tcdent@gmail.com

Usage

$api = new RestClient(array(
    'base_url' => "http://api.twitter.com/1/", 
    'format' => "json"
));
$result = $api->get("statuses/public_timeline");
if($result->info->http_code == 200)
    json_decode($result->response);

Configurable Options

headers - An associative array of HTTP headers and values to be included in every request.
curl_options - cURL options to apply to every request. These will override any internally generated values.
user_agent - User agent string.
base_url - URL to use for the base of each request.
format - Format to append to resource.
username - Username to use for basic authentication. Requires password.
password - Password to use for basic authentication. Requires username.

Options can be set upon instantiation, or individually afterword:

$api = new RestClient(array(
    'format' => "json", 
    'user_agent' => "my-application/0.1"
));

-or-

$api = new RestClient;
$api->set_option('format', "json");
$api->set_option('user_agent', "my-application/0.1");

About

A generic REST API client for PHP

License:MIT License


Languages

Language:PHP 85.0%Language:Perl 15.0%