Zadejte hledaný výraz...

Php curl a put

SerialCrash
verified
rating uzivatele
(6 hodnocení)
15. 5. 2020 23:17:47
Zdravim
neviete ako do php curl cez http PUT napisat na na priklade takuto poziadku:
URL: https://nieco.com
JSON data:
{
"ips":
}
15. 5. 2020 23:17:47
https://webtrh.cz/diskuse/php-curl-a-put/#reply1452074
Michal Pešat
verified
rating uzivatele
(2 hodnocení)
15. 5. 2020 23:34:57
// get cURL resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, 'https://nieco.com/');
// set method
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
// return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// set headers
curl_setopt($ch, CURLOPT_HTTPHEADER, );
// json body
$json_array =
];
$body = json_encode($json_array);
// set body
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
// send the request and save response to $response
$response = curl_exec($ch);
// stop if fails
if (!$response) {
die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
}
echo 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;
echo 'Response Body: ' . $response . PHP_EOL;
// close curl resource to free up system resources
curl_close($ch);
15. 5. 2020 23:34:57
https://webtrh.cz/diskuse/php-curl-a-put/#reply1452073
SerialCrash
verified
rating uzivatele
(6 hodnocení)
16. 5. 2020 00:05:54
vdaka velmy pekny funguje to :)
Napsal obchodniuspech;1583996
// get cURL resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, 'https://nieco.com/');
// set method
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
// return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// set headers
curl_setopt($ch, CURLOPT_HTTPHEADER, );
// json body
$json_array =
];
$body = json_encode($json_array);
// set body
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
// send the request and save response to $response
$response = curl_exec($ch);
// stop if fails
if (!$response) {
die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
}
echo 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;
echo 'Response Body: ' . $response . PHP_EOL;
// close curl resource to free up system resources
curl_close($ch);
16. 5. 2020 00:05:54
https://webtrh.cz/diskuse/php-curl-a-put/#reply1452072
Pro odpověď se přihlašte.
Přihlásit