Skip to content

buzzvsnestful

MIT 11 2 1,919
5.6 thousand (month) Nov 11 2011 1.2.1(2 years ago)
507 3 11 NA
Apr 20 2010 41.3 thousand (month) 1.1.4(4 years ago)

Buzz is a lightweight PHP library for issuing HTTP requests. It is built on top of the PHP curl extension and is designed to be easy to use and flexible.

While buzz isn't as feature rich as other clients it still supports http2 and is relatively easy to use.

Nestful is a Ruby library for making HTTP requests. It is designed to provide a simple, easy-to-use interface for making requests and handling responses. Nestful is often used for making requests to RESTful APIs.

One of the main features of Nestful is its ability to automatically parse JSON and XML responses and return them as Ruby objects. This allows developers to easily access the data returned by an API without having to manually parse the response.

Netful is aimed at interacting with rest APIs and provides a convenient interface (see example below)

Highlights


http2uses-curl

Example Use


use Buzz\Client\Curl;
use Buzz\Message\Request;
use Buzz\Message\Response;

$client = new Curl();
// GET request
$request = new Request('GET', 'http://httpbin.org/get');
$response = new Response();
$client->send($request, $response);
echo $response->getContent();

//POST request
$request = new Request('POST', '/api/resource', 'http://example.com');
$request->setContent(json_encode(['name' => 'John Doe']));
// we can also add headers or cookies:
$request->addHeader('Content-Type: application/json');
$request->addHeader('Cookie: name=foobar');
$response = new Response();
$client->send($request, $response);
echo $response->getContent();

// Buzz also supports http2 (see the 2.0 parameter)
$response = $client->sendRequest(
  new Request('GET', 'https://http2.golang.org/serverpush', [], null, '2.0')
);
require 'nestful'

# GET request
response = Nestful.get('http://httpbin.org/get')
puts response.body
puts response.code
puts response.headers

# POST request
response = Nestful.post(
    'http://httpbin.org/post', 
    :format => :json, :payload => { :title => 'foo', :body => 'bar', :userId => 1 }
)
puts response.body

# establish interface to a specific API
class Charge < Nestful::Resource
  endpoint 'https://api.stripe.com/v1/charges'
  options :auth_type => :bearer, :password => 'sk_bar'

  def self.all
    self.new(get)
  end

  def self.find(id)
    self.new(get(id))
  end

  def refund
    post(:refund)
  end
end

Charge.all #=> []
Charge.find('ch_bar').amount

Alternatives / Similar


Was this page helpful?