PHP code example of juanchosl / curlclient
1. Go to this page and download the library: Download juanchosl/curlclient 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/ */
juanchosl / curlclient example snippets
use JuanchoSL\CurlClient\CurlRequest;
$extra_headers = ['Content-type' => 'application/json'];
$curl = new CurlRequest();
$curl->setSsl(true);
$response = $curl->post($url, json_encode([$key => $value]), $extra_headers);
$http_code = $response->getResponseCode();
$body = $response->getBody();
use JuanchoSL\CurlClient\Engines\Http\CurlHttpRequest;
$extra_headers = ['Content-type' => 'application/json'];
$curl = new CurlHttpRequest();
$curl->setSsl(true);
$response = $curl->post($url, json_encode([$key => $value]), $extra_headers);
$http_code = $response->getResponseCode();
$body = $response->getBody();
use JuanchoSL\CurlClient\Engines\Ftp\CurlFtpRequest;
$curl = new CurlFtpRequest();
$curl->setSsl(true);
$curl->setPasive(true);
$response = $curl->post("ftps://username:password@host:port/directory/filename.ext", file_get_contents("/path/local/file.ext"));
$body = $response->getBody();
use JuanchoSL\CurlClient\Engines\Email\CurlEmailRequest;
$curl = new CurlEmailRequest();
$curl->setSsl(true);
$response = $curl->post("smtps://username:password@host:port", file_get_contents("/path/to/full/formed/message.eml"));
use JuanchoSL\CurlClient\Engines\Http\CurlHttpHandler;
$extra_headers = ['Content-type' => 'application/json'];
$curl = new CurlHttpHandler();
$curl->setSsl(true);
$curl_handle = $curl->preparePost($url, json_encode([$key => $value]), $extra_headers);
$request = (new RequestFactory)
->createRequest('GET', 'https://www.tecnicosweb.com')
->withProtocolVersion('1.1')
->withHeader('User-agent',(new UserAgent())->getDesktopWindows(1))
->withAddedHeader('Accept','text/html');
$response = (new PsrCurlClient)->sendRequest($request);
print_r($response);