Giter VIP home page Giter VIP logo

curlx's Introduction

CurlX 0.0.4

CurlX is a HTTP basic library written in PHP, for human beings and has no dependencies, working with PHP 7.4+.

CurlX allows you to send GET, POST, PUT, DELETE AND MORE HTTP METHODS. You can add headers, form data, json data, and parameters with simple arrays, and access the response data in the same way. You can add a HTTP TUNNEL with PROXY, server ROTATIONS like LUMINATI, APIFY, IPVANISH.

GET, POST AND CUSTOM Syntax

# GET
$CurlX::Get("https://api.myip.com/");

# POST
$CurlX::Post("https://api.myip.com/", "my_form_id=test&hello=mom");

# CUSTOM
$CurlX::Custom("https://api.myip.com/", "HEAD");
$CurlX::Run();

HTTP TUNNEL SYNTAX

# PROXY (http/s, socks4, socks5)
$server = [
    "METHOD" => "TUNNEL",
    "SERVER" => "47.254.145.99:3128"
];

# LIMINATI valid syntax example
$session => mt_rand();
$server = [
    "METHOD" => "CUSTOM",
    "SERVER" = "http://zproxy.lum-superproxy.io:22225",
    "AUTH" => "lum-customer-hl_876f552a-zone-static-route_err-pass_dyn-country-RU-session-$session:my_ultra_secret_password"
];

# APIFY valid syntax example
$server = [
    "METHOD" => "CUSTOM",
    "SERVER" = "http://proxy.apify.com:8000",
    "AUTH" => "auto:my_ultra_secret_password"
];

# IPVANISH valid syntax example
$server = [
    "METHOD" => "CUSTOM",
    "SERVER" => "akl-c12.ipvanish.com:1080",
    "AUTH"   => "my_zone_customer_id:my_zone_customer_password"
];

GET SYNTAX

#Simple GET
$test0 = $CurlX::Get("http://httpbin.org/get");

#GET with Custom Headers
$headers = array(
    "Host: api.myip.com",
    "my-custom-header: my-header-value"
);
$test1 = $CurlX::Get("http://httpbin.org/get", $headers);

#GET with Headers and Cookie
$cookie = uniqid();
$test2 = $CurlX::Get("http://httpbin.org/get", $headers, $cookie);

#GET with Headers, Cookie and Proxy Tunnel
$server = [
    "METHOD" => "TUNNEL",
    "SERVER" => "47.254.145.99:3128"
];
$test3 = $CurlX::Get("http://httpbin.org/get", $headers, $cookie, $server);
#After all request was complete, you can delete the cookie file, Only when you use the $cookie parameter.
$CurlX::deleteCookie();

# Response status of the request
var_dump($test3->success);
// bool(true)

# Status code of the request
var_dump($test3->code);
// int(200)

# Content type of the request
var_dump($test3->headers["response_headers"]["content-type"]);
// string(24) "text/html; charset=UTF-8"

# Body response of the request
var_dump($test3->body);
// string(51) "{...}"

POST SYNTAX

#Simple POST with NULL data
$test0 = $CurlX::Post("http://httpbin.org/post");

#POST with Data-form and Custom Headers
$headers = array(
    "Host: httpbin.org",
    "my-custom-header: my-header-value"
);
$test1 = $CurlX::Post("http://httpbin.org/post", "test_ID=666&hello=mom", $headers);

#POST with Json-Data and Custom Headers
$data = array(
    "hello" => "mom",
    "key" => "value"
);
$test2 = $CurlX::Post("http://httpbin.org/post", $data, $headers);

#POST with Custom-Data, Custom Headers and Cookie
$cookie = uniqid();
$test3 = $CurlX::Post("http://httpbin.org/post", $data, $headers, $cookie);

#POST with Json-Data, Custom Headers, Cookie and Proxy Tunnel
$server = [
    "METHOD" => "TUNNEL",
    "SERVER" => "47.254.145.99:3128"
];
$test4 = $CurlX::Post("http://httpbin.org/post", $data, $headers, $cookie, $server);
#After all request was complete, you can delete the cookie file, Only when you use the $cookie parameter.
$CurlX::deleteCookie();

# Response status of the request
var_dump($test3->success);
// bool(true)

# Status code of the request
var_dump($test4->code);
// int(200)

# Content type of the request
var_dump($test4->headers["response_headers"]["content-type"]);
// string(24) "..."

# Body response of the request
var_dump($test4->body);
// string(51) "{...}"

Other functions

    // Set a custom option to current CURL structure
    $CurlX::SetOpt([CURLOPT_HTTPAUTH => CURLAUTH_BEARER]);

    // Get a rand line from text file
    $CurlX::GetRandVal("proxies.txt");
    // Output: 202.137.25.8:8080

    // Parse a string by two specify strings
    $str = "curlx is the best for web scraping";
    $CurlX::ParseString($str, "curlx", "scraping")
    // Output: is the best for web

    // Clean all spaces from a string
    $CurlX::CleanString($str);
    // Output: curlxisthebestforwebscraping

    /**
     * Show all data process|errors of the request
     * 
     * Debug() : now support pretty print to html and json
     * @param true = json response
     * @param false = html response
     * 
     * Recommended for develop work space
     * 
    */
    $CurlX::Debug(false);

More?

Features

  • International Domains and URLs
  • Custom Tunnel Http with Proxy, Socks, Luminati, Apify, IpVanish
  • Cookie data reutilization
  • Custom HTTP METHODS

Installation

Install source from GitHub

To install the source code:

$ git clone https://github.com/devblack/curlx.git

And include it in your scripts:

require_once "CurlX.php";
$CurlX = new CurlX;

Install source from zip/tarball

Alternatively, you can fetch a tarball or zipball:

$ curl -L https://github.com/devblack/curlx/tarball/master | tar xzv
(or)
$ wget https://github.com/devblack/curlx/tarball/master -O - | tar xzv

Contribute

  1. Check for open issues or open a new issue for a feature request or a bug
  2. Fork the repository on Github to start making your changes to the master branch (or branch off of it)
  3. Write a test which shows that the bug was fixed or that the feature works as expected
  4. Send a pull request and bug me until I merge it

curlx's People

Contributors

devblack avatar mateodioev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

curlx's Issues

Where you gone man deleted TG !!

Have any new improvement for the bot in your mind
i want to expand it to that forum which we talked before
contact me on TG my name is same as username

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.