我试图用POST数据调用我自己的Restful API;但它不起作用!如果我在这里遗失了什么,请你告诉我吗?
我在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);
现在在索引中:
//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);
由于