使用Volley做cURL請求。
private void getResponse(){
String URL = "https://api.infermedica.com/v2/symptoms";
RequestQueue queue = Volley.newRequestQueue(this);
StringRequest request = new StringRequest(Request.Method.GET, URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.e("Check Response",response);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("Check Error","Error");
}
}
){
@Override
public byte[] getBody() throws AuthFailureError {
return new byte[]{};
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String> map = new HashMap<>();
map.put("Content-Type","application/json");
map.put("Accept", "application/json");
map.put("app_id","90f10c6a");
map.put("app_key","9d23d9250d9f2ee8aa49efda732e4d3d");
return map;
}
};
request.setRetryPolicy(new DefaultRetryPolicy(15000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_MAX_RETRIES));
queue.add(request);
}
https://developer.infermedica.com/docs/authentication基本示例是否在粘貼憑據時起作用? –
我無法理解這個例子。我不知道我會在哪裏添加我的憑據以進行回覆以及如何進行卷曲 –
只需打開一個控制檯並在那裏運行它。我想你必須先學習控制檯和捲曲。 –