Как попасть по URL с заголовком Content-Type, установленным в application / json.
Мой код возвращает «запрос не выполнен» (другая сторона условия).Я новичок, поэтому, пожалуйста, помогите мне понять, почему это не работает.
Код:
$data_string=json data here;
$ch = curl_init('www.here is url');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
if(curl_exec($ch))
echo "request successfull";
else
echo "request not successfull"
curl_close($ch);