Skip to content

A small PHP-Lib/Module to make fetching data via PHP-Curl easy.

License

Notifications You must be signed in to change notification settings

Rocco-Gossmann/PHP-Curl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rogoss PHP-CURL

a small Lib meant to make fetching data via PHP-Curl easy.

Usage

<?php
    require_once "path/to/the/clone/of/this/repo/Curl.php",

    use \rogoss\Curl\Curl;

    /** @var \rogoss\Curl\FetchResult $oFetch */
    $oFetch = Curl::GET()                       //<- define your Method: POST(), DELETE() and PUT() are also possible
        ->url("http://request.to.somewhere")    // <- define where to send the request to
        ->header("accept", "application/json")  // <- set the request header 
        ->header("x-custom-header", "hello world")   
        //...
        ->param("foo", "bar")       // <- add Request-Parameters
        ->param("fizz", "buzz")
        //...
        ->debug(true) // <- enable Debug-Output to see the Raw Data send between servers
        //...
        ->exec() // <- run the Request and Fetch the Response
    ;

    if(empty($oFetch)) {
        echo "request failed, make sure the server is reachable and the URL is not empty";
        exit; 
    }

    // Available Fields on FetchResult
    $oFetch->protokoll;  // HTTP-Protocol
    $oFetch->status;     // HTTP Response-Status (200 OK, 404 Not Found, etc.)
    $oFetch->statusText; // Default text connected to the status "OK" for 200, etc. .. 
    $oFetch->body;       // The Raw Response-Body in plain-text format
    $oFetch->headers;    // An Array containing all Response-Headers

About

A small PHP-Lib/Module to make fetching data via PHP-Curl easy.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages