curlx
Version 0.0.4
curlx 인간을 위해 PHP로 작성된 HTTP 기본 라이브러리이며 PHP 8.2 이상에서 작동하며 종속성이 없습니다.
curlx 사용하면 GET , POST , PUT , DELETE 및 기타 HTTP 메소드를 보낼 수 있습니다. 간단한 배열을 사용하여 헤더, 양식 데이터, json 데이터, 매개변수를 추가하고 동일한 방식으로 응답 데이터에 액세스할 수 있습니다. PROXY, LUMINATI, APIFY, IPVANISH와 같은 서버 ROTATIONS를 사용하여 HTTP 터널을 추가할 수 있습니다.
# 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 ();
# 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 "
];
# 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 File
$ 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 requests were complete, you can delete the cookie file, Only when you use the $cookie parameter.
$ curlx -> deleteCookie ();
# Response status of the request
var_dump ( $ test3 -> isSuccess ());
// bool(true)
# Status code of the request
var_dump ( $ test3 -> getStatusCode ());
// int(200)
# Content type of the request
var_dump ( $ test3 -> getHeaders ()[ " response " ][ " content-type " ]);
// string(24) "text/html; charset=UTF-8"
# Body response of the request
var_dump ( $ test3 -> getBody ());
// string(51) "{...}"
#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 requests were complete, you can delete the cookie file, Only when you use the $cookie parameter.
$ curlx -> deleteCookie ();
# Response status of the request
var_dump ( $ test3 -> isSuccess ());
// bool(true)
# Status code of the request
var_dump ( $ test4 -> getStatusCode ());
// int(200)
# Content type of the request
var_dump ( $ test4 -> getHeaders ()[ " response " ][ " content-type " ]);
// string(24) "..."
# Body response of the request
var_dump ( $ test4 -> getBody ());
// string(51) "{...}"
// Set a custom option to current CURL structure
$ curlx -> setOpt ([ CURLOPT_HTTPAUTH => CURLAUTH_BEARER ]);
/**
* Show all data process|errors of the request
*
* debug(): now supports cli and json print
*
* Recommended for develop work space
*/
$ curlx -> debug ();
소스 코드를 설치하려면:
$ git clone https://github.com/devblack/curlx.git
그리고 이를 스크립트에 포함하세요.
require_once " curlx .php";
$ curlx = new curlx ();
또는 tarball이나 zipball을 가져올 수도 있습니다.
$ curl -L https://github.com/devblack/curlx/tarball/master | tar xzv
(or)
$ wget https://github.com/devblack/curlx/tarball/master -O - | tar xzv
master
브랜치(또는 마스터 브랜치에서 분기) 변경을 시작하세요.