Код: Выделить всё
curl -s -i -k -X POST https://myserver.mydomain.com/rest/login -H 'Content-Type: application/json' -d '{"username": "myuser","password":"mypass","domain":"mydomain"}'
Я попытался превратить это в запрос на завивку PHP с помощью следующего код:
Код: Выделить всё
$ch = curl_init();
$postFields = json_encode([
"username"=>$myuser,
"password"=>$mypass,
"domain"=>$mydomain
]);
curl_setopt($ch, CURLOPT_URL, "https://" . $myserver . "/rest/login");
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type:application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$webresponse = curl_exec($ch);
$info = curl_getinfo($ch);
print_r($webresponse);
print_r($info);
Код: Выделить всё
Array
(
[url] => https://myserver.domain.com/rest/login
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.007508
[namelookup_time] => 0.008522
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[redirect_url] =>
[primary_ip] =>
[certinfo] => Array
(
)
[primary_port] => 0
[local_ip] =>
[local_port] => 0
[http_version] => 0
[protocol] => 0
[ssl_verifyresult] => 0
[scheme] =>
[appconnect_time_us] => 0
[connect_time_us] => 0
[namelookup_time_us] => 8522
[pretransfer_time_us] => 0
[redirect_time_us] => 0
[starttransfer_time_us] => 0
[total_time_us] => 7508
)
Подробнее здесь: https://stackoverflow.com/questions/792 ... d-into-php
Мобильная версия