firstvector/simplephpcurl

Simple library for performing cURL requests

dev-master 2015-10-22 19:03 UTC

This package is auto-updated.

Last update: 2024-12-10 21:11:36 UTC


README

Simple library for performing cURL requests.

Usage

An example of request with authorization via OAuth or Bearer token.

const CONSUMER_KEY = 'value';
const CONSUMER_SECRET = 'value';
const OAUTH_ACCESS_KEY = 'value';
const OAUTH_ACCESS_SECRET = 'value';

$token = new SimplePHPCurl\OAuthToken(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_ACCESS_KEY, OAUTH_ACCESS_SECRET);
// $token = new SimplePHPCurl\BearerToken('https://api.twitter.com/oauth2/token', CONSUMER_KEY, CONSUMER_SECRET);

$curl = new SimplePHPCurl\Request('https://api.twitter.com/1.1/statuses/user_timeline.json');
$curl->authorization($token);
$curl->get([
    'screen_name' => 'firstvector',
    'count' => 2,
]);
var_dump(
    $curl->execute()
);

An example of simple GET request.

$curl = new SimplePHPCurl\Request('http://firstvector.org');
$curl->get();
var_dump(
    $curl->execute()
);