Van een website heb ik deze 2 stukjes code gehaald:
curl -X POST https://192.168.1.2/api/auth/login -H "Content-Type: application/json" --insecure -d '{"username":"YOURUSER", "password":"YOURPASS"}' -c /tmp/cookies.txt 2>&1 -k --silent > /dev/null
en:
curl "https://192.168.1.2/proxy/protect/api/bootstrap" -H 'Cookie: TOKEN=' --cookie /tmp/cookies.txt --cookie-jar /tmp/cookies.txt -H 'Upgrade-Insecure-Requests: 1' 2>&1 -k --silent
Dit lijkt me op CURL code die je op de een of andere manier in een soort "Command line" moet uitvoeren?
Ik zou dit echter graag in PHP doen, maar ik weet helaas niet hoe ik dit moet "omzetten" zodat ik er standaard "PHP CURL" van kan maken.
Normaal gebruik ik daar bijvoorbeeld iets zoals onderstaand voor:
<?php
$handle = curl_init();
$url = "https://localhost/curl/theForm.php";
// Array with the fields names and values.
// The field names should match the field names in the form.
$postData = array(
'firstName' => 'Lady',
'lastName' => 'Gaga',
'submit' => 'ok'
);
curl_setopt_array($handle,
array(
CURLOPT_URL => $url,
// Enable the post response.
CURLOPT_POST => true,
// The data to transfer with the response.
CURLOPT_POSTFIELDS => $postData,
CURLOPT_RETURNTRANSFER => true,
)
);
$data = curl_exec($handle);
curl_close($handle);
echo $data;
Weet iemand hoe ik dit moet aanpakken?
Alvast vriendelijk bedankt!
Grtz,
Sjef