2016-10-18 162 views
0

使用REST API(https://qwintry.com/ru/api-docs),嘗試使用註冊新用戶的make方法。 有API文檔的有關注冊用戶請求的一部分:使用REST API

Login 
Request example: 
<?php 
    define('site_url', 'qwintry.com'); 
    $url = 'https://' . site_url.'/api-rest/v2/user/login'; 
    $data = array ( 
      'email' => '[email protected]', 
      'password' => '123', 
      'key' => '9e4fddbb3adc4c67f74bb2b7757cebf9', 
    ); 
    $data_string = http_build_query($data); 

    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_POST, true); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
    curl_setopt($ch, CURLOPT_HEADER, 1); 
    $response = curl_exec($ch); 
    curl_close($ch); 
    print_r($response); 
Parameters: 
email — E-mail of user 
password — Password 
key — Unique key of request 

有我的實現方法loginUser的:

@Service 
public class LogisticServiceImpl implements LogisticService { 
    private final String BASE_URL = "http://www.qwintry.com/api-rest/v2"; 

    @Override 
    public String userLogin(String email, String password) throws Exception { 
     String url = BASE_URL + "/user/login"; 
     Map<String, Object> params = new HashMap<>(); 
     params.put("email", email); 
     params.put("password", password); 
     HttpResponse<String> jsonResponse = Unirest.post(url).fields(params).asString(); 

     return jsonResponse.getBody(); 
    } 

永久獲得這樣的響應:

301永久移動

301永久移動


nginx

預期的Json格式。 我做錯了什麼?在文檔

+0

你正在尋找已被移動到一個新的URL permanently.look新的URL資源。 –

回答

0

發現錯誤,它不是職位,但GET請求,現在一切正常