I created a rest APi for my website. The GET methods are working fine. For POST method, api is not getting the data posted back to it. I wrote this code but its giving error due to Notice: Trying to get property of non-object in
$response = file_get_contents('http://myapi.com/object/post.php');
$data = json_decode($response);
$object->id = $data->id;
$object->name = $data->name;