Contoh PHP Curl Strapi POST Dengan Token
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost:1337/api/mahasiswas',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"data": {
"nama": "Hello",
"kelas": "ok"
}
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Bearer f795a06dadc3f84eab739e57be8c3af5f01936f6438b9367482b0142ac9da63c5fd2665fc025d9699b87287064685d2315b6daa38f5b4c4bc28efcad451280eb29979fb73bd2c8dab30d39d170b5cd9199ccb1e563d5ca9ef6c8b79e21c857011519df2e59ceffd15cc2a0dfd57c2b3f080a5afdeb6a20c425023244b59dfe4b'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Lanjut Part : 1
Muhammad Ullil Fahri
WA : 089696380422
Tautan WA : https://wa.me/message/SG4YA2XQP5FPE1