Отправка запроса с заголовками и данными:
curl --insecure -X POST 'https://remote-server.com/endpoint' \
-H 'content-type: application/json; charset=UTF-8' \
-H 'referer: http://ya.ru/' \
-H 'Host: remote-server.com:443' -H 'X-Forwarded-For: 85.145.65.234' -H 'User-Agent: php2curl Agent - github.com/biganfa/php2curl' \
--data '{"formData":{"someId":"123456777","fieldsData":[{"name":"fieldName1","value":"Value1"},{"name":"fieldName2","value":"Value2"}],"options":{"someOption":true}}}' \
Получить время загрузки страницы:
curl "https://domain.com/" -s -o /dev/null -w "response_code: %{http_code}\n
dns_time: %{time_namelookup}\n\
connect_time: %{time_connect}\n\
AppCon time:\t%{time_appconnect}\n\
pretransfer_time: %{time_pretransfer}\n\
starttransfer_time: %{time_starttransfer}\n\
total_time: %{time_total}"
Получить время загрузки страницы(2 способ):
time curl -I -X GET https://domain.com/api/v1/endpoint
Чтобы получить страничку с удаленного сервера нужно выполнить следующий код:
$curl_cpr = curl_init();
curl_setopt($curl_cpr,CURLOPT_URL,'http://11.22.33.44/phpfile.php');
curl_setopt($curl_cpr,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl_cpr, CURLOPT_TIMEOUT, 2);
$out_cpr = curl_exec($curl_cpr);
curl_close($curl_cpr);
echo $out_cpr;
curl -X 'PUT' -d '{"param1":"test1","param2":"test3"}' \http://test.com/1
curl -H "Host: example.com" http://localhost/
curl -H "Host: bi.zone" http://127.0.0.1/
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://hostname/resource
curl -X 'PUT' -d '{"param1":"test1","param2":"test3"}' \http://test.com/1
curl -u https://my-test-api.com/endpoint1
curl -w "%{time_total}\n" -o /dev/null -s site.local