我正在開發一個android應用程序,我已訂閱對話框以收集用戶電子郵件。我想將這些用戶電子郵件添加到MailChimp列表中。這是我到目前爲止的代碼,但是這樣我得到了一個Authorization failed
錯誤。如何將新成員添加到Android應用程序的MailChimp列表中?
public void suscribeMailChamp(String listid){
String url = "https://us16.api.mailchimp.com/3.0/lists/" + listid + "/members/";
// Instantiate the RequestQueue.
RequestQueue queue = Volley.newRequestQueue(this);
StringRequest sr = new StringRequest(Request.Method.POST,url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
//
Toast.makeText(MainActivity.this , "success" , Toast.LENGTH_SHORT).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(MainActivity.this , error.toString() , Toast.LENGTH_SHORT).show();
}
}){
@Override
protected Map<String,String> getParams(){
Map<String,String> params = new HashMap<String, String>();
params.put("email_address","[email protected]");
params.put("status","unsubscribed");
return params;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String> params = new HashMap<String, String>();
params.put("Content-Type","application/x-www-form-urlencoded");
params.put("Authorization" , "apikey");
return params;
}
};
queue.add(sr);
}
請給我的錯誤 – Meikiem
com.android.volley.AuthFailureError有意外的響應代碼401 https://us16.api.mailchimp.com/3.0/lists/6e520e2c45/members/ –
任何人都知道我在做什麼錯誤 –