其實我一直在使用angularjs和restfullapis.i忘記身份驗證部分發送密鑰給丟失的用戶郵件以獲取重置密碼面板。用戶點擊郵件中的驗證網址(http://workless/services/user/reset_pwd_confirm?verification_id=72e03c6aa3268cd37067243945ac69aa&user_id=5)以下apis電話。如何使用php curl從api發佈數據重定向?
private function reset_pwd_confirm(){
if($this->get_request_method() != "GET"){
$this->response('',406);
}
$verification_id = $this->_request['verification_id'];
$user_id = $this->_request['user_id'];
if(!empty($verification_id) && !empty($user_id) && $user_id > 0){
$tm=time()-86400;
$query = "SELECT user_id FROM user_pwd_reset WHERE user_id='".$user_id."' AND act_key='".$verification_id."' AND time > ".$tm."";
$get_user = $this->db->get_row($query);
if($this->db->num_rows == 1){
$curl = curl_init('http://localhost:3000/#/reset');
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, 'user_id='.$user_id);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_exec($curl);
}else{
$success = array('status' => "Failed", "msg" => "key and user are not match.");
$this->response($this->json($success),404);
}
}else{
$success = array('status' => "Failed", "msg" => "Invaild verification or user id.");
$this->response($this->json($success),404);
}
}
在這裏,我需要移動稱爲http://localhost:3000/#/reset與後USER_ID角頁面,爲此,我用捲曲正如我上面提到但返回錯誤爲「不能發佈/」。 是什麼問題?請告訴我。 我認爲問題是從http get方法請求發佈,是嗎? 請給我的解決方案...
選中此http://stackoverflow.com/問題/ 27670975/can-post-curl-to-nodejs-socket-io#並且發佈你的api代碼,以便我們可以看到什麼是錯誤的。 –