I need your help to check whats wrong with my code. I had tried to post a json data from postman and it returnen a correct response. But the following code always returns a wrong response.
<?php
$data_login = array('email'=>'[email protected]','password'=>'hahaha','confirmation_password'=>'hahaha');
$api_data = json_encode($data_login);
$api_url = 'http://dev.badr.co.id/freedom/auth/register';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $api_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
wrong response :
{"success":false,"message":"1000: Not a valid request"}
correct response :
{
"success": true,
"message": "user registration success",
"data": null
}
This return a correct response if i post the data using postman :
{"success":false,"message":"1000: Not a valid request"}that means you are not usingAPIin it's told way{"success":false,"message":"1000: Not a valid request"}. I have no idea if this is a working endpoint or not. I can't even work out what Postman or Freedom Php is, from leafing through the website.var_dump($result)please.