I am trying to call my own Restful API with POST data; but it does not work ! Could you please let me know if I am missing something here?
My code in login.php:
$ch = curl_init();
$UN = htmlspecialchars(strip_tags($_POST['user']));
$PWD = htmlspecialchars(strip_tags($_POST['password'], ENT_QUOTES));
$data = array('action' => 'authenticateUser',
'username'=>$UN,
'password'=>$PWD
);
curl_setopt($ch, CURLOPT_URL, 'my URL goes Here');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
and now in index:
//The following require once echo the response from my restful API( I am not sure why it does echo though!) :[{"username":"John Smith","password":"*32ewrer43","firstName":"John","lastName":"Smith"}
require_once('includes/login.php');
$response = json_decode($response);
//The following line echo int(1) ! so why not my data?!
var_dump($response);
Thanks