This project is read-only.

Documentation & examples

Please check the documentation and examples in the latest release - http://curly.codeplex.com/releases/
Soon there will be more examples

Requirements

PHP 5.3.0 compiled with the cURL library

Installation

Just copy the 'lib' directory and include the Loader.php file.

Sample code:
<?php

include "libs/Curly/Loader.php";

use Curly\HttpClient;
use Curly\Request;


$client = HttpClient::create();
$client->attach( new Request( "http://google.com" ) );
$client->attach( new Request( "http://yahoo.com" ) );
$client->attach( new Request( "http://bing.com" ) );

$client->execute();

foreach( $client->getFinishedRequests() as $finishedRequest )
{
    $response = $finishedRequest->getResponse();
    
    echo "<pre>";
    echo "<b>Requested URI: </b>" . $finishedRequest->getUri() . "\n";
    echo "<b>Final URI: </b>" . $response->getUri() . "\n";
    echo "<b>Status: </b>" . $response->getStatus()->getCode() . " " . $response->getStatus() . "\n";
    
    echo "<b>Charset: </b>" . $response->getCharset() . "\n";
    echo "<b>Content-Type: </b>" . $response->getContentType() . "\n";
    echo "<b>Content-Length: </b>" . $response->getContentLength() . "\n";
    
    echo "<b>Cookies: </b>\n";
    foreach( $response->cookies() as $cookie )
    {
        echo "\t{$cookie} \n";
    }

    echo "<b>Headers: </b>\n";
    foreach( $response->headers() as $name => $value )
    {
        echo "\t{$name} = {$value}\n";
    }
    
    echo "<b>Content: </b>\n";
    echo htmlspecialchars( substr( $response->getContent(), 0, 1000 ) ) . " ...";
    echo "</pre><br><br>";
}

Last edited Jul 26, 2011 at 4:23 PM by Kicok, version 2

Comments

No comments yet.