PHP code example of srvclick / scurl
1. Go to this page and download the library: Download srvclick/scurl library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
srvclick / scurl example snippets
use Srvclick\Scurl\Scurl_Request as SCURL;
$curl = new SCURL;
$curl->setUrl('https://example.com');
$response = $curl->Send();
echo $response->getBody();
$curl->setMethod("POST");
$curl->setParameters([
'user' => 'user',
'password' => 'password',
]);
$curl->setConfigs([
'custom_method' => 'PUT'
])
$curl->setProxy([
'proxy' => '127.0.0.1',
'proxy_port' => '9090'
]);
$curl->setProxy([
'proxy' => '127.0.0.1',
'proxy_port' => '9090',
'proy_user' => 'root',
'proxy_pass' => 'toor'
]);
$curl->setConfigs([
'user-agent' => 'Mozilla'
])
$curl->setHeaders([
'user-agent: Mozilla'
])
$curl->setConfigs([
'ssl_verifypeer' => 'false'
]);
$curl->useCookie(true);
$curl->setCookieName('Random Cookie Name');
$curl->downloadFile("/path/","filename.ext");
$curl->setInterceptCookie(true);
$responseCookies = $response->getResponseCoookies(); //Array
$curl->setConfigs([
'use_proxy' => true,
'max_redirs' => 10,
'timeout' => 30,
'http_version' => CURL_HTTP_VERSION_1_1,
'return_transfer' => true,
'ssl_verifypeer' => true,
'follow' => false,
'encondig' => "",
'user-agent' => 'SCURL by SrvClick',
'header' => [],
'http_auth' => true,
'http_user' => 'admin',
'http_pass' => 'admin'
]);
$curl = new SCURL();
$curl->setMulticurl();
for ($i = 0; $i < 10; $i++) {
$curl->MultiUrl('https://jsonplaceholder.typicode.com/todos/'.$i);
$curl->downloadFile(__DIR__."/downloads/","item_".$i.".json");
}
$response = $curl->Send();
for ($i = 0; $i < $response->getCount(); $i++) {
echo "Peticion ".$i." Con HTTP STATUS ".$response->getStatus($i)."\n";
}
$curl->NipSetRange($core, $limit);
$curl->NipMultiUrl('https://example.com/nip');
$curl->NipSetParams(function($nip){
return ['otp' => str_pad($nip ,4,0,STR_PAD_LEFT)];
//return '{"nip":"'.str_pad($nip ,4,0,STR_PAD_LEFT).'"}'; //Example 2
}
$response = $curl->Send();
if($response->checkNip(function ($response) {
$decode = json_decode($response,true);
if ($decode['success'] == "yes") return true;
return false;
})){
echo "NIP: ".$response->getNip()."\n";
}else{
echo "Nip not found\n";
}
);