2017 © Pedro Peláez
 

library curl

A Simple Curl Interface

image

ans/curl

A Simple Curl Interface

  • Sunday, September 16, 2012
  • by eusonlito
  • Repository
  • 2 Watchers
  • 1 Stars
  • 47 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Curl

This script works as simple curl interface, (*1)

You can use to get remote content using GET, POST or CUSTOM methods, (*2)

Usage

<?php
include (__DIR__.'/libs/ANS/Curl/Curl.php');

# Load and init Curl
$Curl = new \ANS\Curl\Curl;

$Curl->init('https://github.com/');

# GET request
$response = $Curl->get('eusonlito.atom');

# POST request
$response = $Curl->post('search', array(
    'q' => 'curl',
    'start_value' => 1,
    'type' => 'Everything',
    'language' => 'PHP'
));

# Custom request
$response = $Curl->custom('DELETE', 'notifications/subscribe', array(
    'repository_id' => 0
));

# Set Cookie
$Curl->setCookie('logged=1');

# Get raw response
$Curl->getResponse();

# Get request info
$Curl->getInfo();

# Process Json response
$Curl->init('https://api.github.com/');

$Curl->setOption(CURLOPT_HTTPHEADER, array(
    'Accept: application/json',
    'Content-Type: application/json; charset=utf-8',
    'Connection: Keep-Alive'
));

$Curl->setJson(true);

$Curl->setOption(CURLOPT_SSL_VERIFYPEER, false);
$Curl->setOption(CURLOPT_USERPWD, 'username:password');

$response = $Curl->get('user/repos');

# Request a URL outside the main server
$Curl->fullGet('http://google.com/');

# Advanced integration (https://github.com/eusonlito/Timer)
include (__DIR__.'/libs/ANS/Timer/Timer.php');

$Timer = new Timer;

$Curl->setTimer($Timer);

$response = $Curl->get('user/repos');

foreach ($Timer->get() as $timer) {
    echo "\n".sprintf('%01.6f', $timer['total']).' - '.$timer['text'];
}

The Versions

16/09 2012

dev-master

9999999-dev https://github.com/eusonlito/Curl/

A Simple Curl Interface

  Sources   Download

AGPL-3.0

The Requires

  • php >=5.3.3

 

curl php