2017 © Pedro Peláez
 

library rest-client

PHP 5.3+ Rest Client

image

jowy/rest-client

PHP 5.3+ Rest Client

  • Friday, December 11, 2015
  • by Atriedes
  • Repository
  • 1 Watchers
  • 3 Stars
  • 4,063 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 9 Forks
  • 1 Open issues
  • 5 Versions
  • 7 % Grown

The README.md

PHP Rest Client

Build Status SensioLabsInsight Scrutinizer Quality Score, (*1)

Simple cURL PHP Rest Client library for PHP 5.3+, (*2)

### Feature

  • Set HTTP Authentication
  • Set HTTP Header
  • Set Curl Options
  • GET, POST, PUT, DELETE Method

### Installation

This library can installed through compose, (*3)

$ php composer.phar require jowy/rest-client:@stable

### Usage

<?php

include 'vendor/autoload.php';

use RestClient\CurlRestClient;

$curl = new CurlRestClient();
$curl->setOptions([CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_SSL_VERIFYPEER => 0]);

var_dump($curl->executeQuery('http://www.google.com'));

// OR....

$curl = new CurlRestClient('http://www.google.com',
    array( // Header data
        'X-API-KEY: 16251821972',
        'OUTPUT: JSON'
    ),
    array( // AUTH (curl)
        'CURLOPT_HTTPAUTH' =>  CURLAUTH_DIGEST,
        'username'  =>  'root',
        'password'  =>  'toor'
    ),
    array(
        CURLOPT_SSL_VERIFYHOST => 0,
        CURLOPT_SSL_VERIFYPEER => 0
    )
);


### Parameter

  • urldescribe target url
  • method define HTTP method can be GET, POST, PUT, DELETE. Default value is DELETE
  • header contain array list of header
  • data contain array list of data
  • auth contain array list of auth

Example fullset usage, (*4)

$curl->executeQuery('http://api.somewebsite.com',
    'POST',
    array(
        'X-API-KEY: 16251821972',
        'OUTPUT: JSON'
    ),
    array(
        'USERNAME' => 'jowy',
        'SERVERID'  => '192882'
    ),
    array(
        'CURLOPT_HTTPAUTH' => CURL_AUTH_DIGEST,
        'username'  =>  'jowy',
        'password'  =>  '123456'
    )
);

// OR USE CONVENIENT METHODS

// GET
$res = $curl->get('customer/details', array(
    'customerId' => 55
));

// POST
$res = $curl->post('customer', array(
    'name' => 'Ole Nordmann',
    'age' => 49,
    'address' => 'Stortingsveien 5',
    'zip' => '0120',
    'city' => 'Oslo'
));

The Versions

11/12 2015

dev-master

9999999-dev

PHP 5.3+ Rest Client

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Prasetyo Wicaksono

11/10 2015

v0.1.3

0.1.3.0

PHP 5.3+ Rest Client

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Prasetyo Wicaksono

17/02 2014

v0.1.2

0.1.2.0

PHP 5.3+ Rest Client

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Prasetyo Wicaksono

07/02 2014

v0.1.1

0.1.1.0

PHP 5.3+ Rest Client

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Prasetyo Wicaksono

04/02 2014

v0.1

0.1.0.0

PHP 5.3+ Rest Client

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Prasetyo Wicaksono