2017-09-28 108 views
0

我正在爲我的iOS應用程序使用API​​。 API通過webservice與數據庫交互。 API是在Slim框架的幫助下編寫的。我在本地服務器上測試了API,並且一切正常。在上傳他們到活服務器我注意到所有的請求與GET方法仍然工作,但要求與POST無法在遠程服務器上工作,並總是返回404頁面未找到錯誤。我剛剛測試了一個API,從POST轉換爲GET,它按預期工作。以下是我的Slim post請求代碼。瘦客戶端請求在遠程服務器上返回404錯誤

\Slim\Slim::registerAutoloader(); 
$app = new \Slim\Slim(); 
$app->post('/forgotPassword', function() use ($app){ 

      verifyRequiredParams(array('email')); 
      $response = array(); 
      // reading post params 
      $email = $app->request->post('email'); 

      $db = new DbHandler(); 
      $res = $db->forgotPassword($email); 

     if ($R = mysqli_fetch_assoc($res)){ 
      $response["error"] = false; 
      $response["message"] = "Password reset instructions have been sent to your email"; 
     } else { 
      $response["error"] = True; 
      $response["message"] = "error"; 
     } 

      echoRespnse(201, $response); 
     }); 

$app->run(); 
+0

嘗試** $電子郵件= $ APP->請求 - > getParam( '電子郵件'); ** –

+0

請求沒有達到那一點。它甚至在此之前發送404錯誤 –

+0

你會寫你的html表單嗎? –

回答

0

這可能是一種替代使用地圖功能,而不是職位:

​​
+0

這個工作,但沒有通過參數獲取參數 –

+0

試試var_dump($ _ POST);你看到任何結果? –

相關問題