Odeslat hromadný e-mail s Android
Odeslat hromadný e-mail na skupinu e-mailových adres s Android
Android : DOKUMENTACE API
- Vytvořit skupinu pomocí Android
- Seznam skupinových polí s Android
- Přidejte pole do skupiny s Android
- Odstranění pole ze skupiny s Android
- Odstranění kontaktu ze skupiny
- Přiřazení země do skupiny s Android
- Seznam skupinových kontaktů s Android
- Přidejte kontakt do skupiny s Android
- Upravit kontakt skupiny pomocí Android
- Smazat kontakt skupiny s Android
- Získejte seznam aktivních chatovacích kanálů s jazykem Android
- Odeslat zprávu prostřednictvím chatu s jazykem Android
- Odeslat soubor prostřednictvím chatu s jazykem Android
- Získejte seznam konverzací v chatu s jazykem Android
- Získejte seznam zpráv z chatu s jazykem Android
- Získejte seznam nepřečtených zpráv z chatu s jazykem Android
Odeslat hromadný e-mail s Android
String afilnet_class="email";
String afilnet_method="sendemailtogroup";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_subject="Afilnet - Test email";
String afilnet_idgroup="1";
String afilnet_email="Afilnet - Test email";
String afilnet_scheduledatetime="";
String afilnet_output="";
// Create an URL request
String sUrl = "https://www.afilnet.com/api/http/?class="+afilnet_class+"&method="+afilnet_method+"&user="+afilnet_user+"&password="+afilnet_password+"&subject="+afilnet_subject+"&idgroup="+afilnet_idgroup+"&email="+afilnet_email+"&scheduledatetime="+afilnet_scheduledatetime+"&output="+afilnet_output;
URL url = new URL(sUrl);
StringBuilder builder = new StringBuilder();
BufferedReader theJSONline = new BufferedReader(new InputStreamReader(url.openStream()));
builder.append(theJSONline.readLine());
String content = builder.toString();
String afilnet_class="email";
String afilnet_method="sendemailtogroup";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_subject="Afilnet - Test email";
String afilnet_idgroup="1";
String afilnet_email="Afilnet - Test email";
String afilnet_scheduledatetime="";
String afilnet_output="";
// Create the POST request
String post = "class="+afilnet_class+"&method="+afilnet_method+"&user="+afilnet_user+"&password="+afilnet_password+"&subject="+afilnet_subject+"&idgroup="+afilnet_idgroup+"&email="+afilnet_email+"&scheduledatetime="+afilnet_scheduledatetime+"&output="+afilnet_output;
// We generate the URL
URL myurl = new URL("https://www.afilnet.com/api/http/");
// We create the connection
HttpURLConnection con = (HttpURLConnection) myurl.openConnection();
con.setDoOutput(true);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("Content-Length", String.valueOf(post.length()));
con.setRequestMethod("POST");
// We build the
OutputStream os = con.getOutputStream();
os.write(post.getBytes());
os.close();
StringBuilder sb = new StringBuilder();
int HttpResult = con.getResponseCode();
if(HttpResult == HttpURLConnection.HTTP_OK)
{
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(),"utf-8"));
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
br.close();
System.out.println(""+sb.toString());
} else {
System.out.println(con.getResponseCode());
System.out.println(con.getResponseMessage());
}
String afilnet_class="email";
String afilnet_method="sendemailtogroup";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_subject="Afilnet - Test email";
String afilnet_idgroup="1";
String afilnet_email="Afilnet - Test email";
String afilnet_scheduledatetime="";
String afilnet_output="";
// Create the POST request
String post = "class="+afilnet_class+"&method="+afilnet_method+"&subject="+afilnet_subject+"&idgroup="+afilnet_idgroup+"&email="+afilnet_email+"&scheduledatetime="+afilnet_scheduledatetime+"&output="+afilnet_output;
// We generate the URL
URL myurl = new URL("https://www.afilnet.com/api/basic/");
// We create the connection
HttpURLConnection con = (HttpURLConnection) myurl.openConnection();
String encoded = Base64.getEncoder().encodeToString((afilnet_user+":"+afilnet_password).getBytes(StandardCharsets.UTF_8));
con.setRequestProperty("Authorization", "Basic "+encoded);
con.setDoOutput(true);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("Content-Length", String.valueOf(post.length()));
con.setRequestMethod("POST");
// We build the
OutputStream os = con.getOutputStream();
os.write(post.getBytes());
os.close();
StringBuilder sb = new StringBuilder();
int HttpResult = con.getResponseCode();
if(HttpResult == HttpURLConnection.HTTP_OK)
{
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(),"utf-8"));
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
br.close();
System.out.println(""+sb.toString());
} else {
System.out.println(con.getResponseCode());
System.out.println(con.getResponseMessage());
}
Parametr | Popis | Povinné / Nepovinné |
---|---|---|
class=email | Požadovaná třída: Třída, na kterou je žádost podána | Povinný |
method=sendemailtogroup | Požadovaná metoda třídy: Metoda třídy, které je žádost podána | Povinný |
user | Uživatel a e-mail vašeho účtu Afilnet | Povinný |
password | Heslo vašeho účtu Afilnet | Povinný |
subject | Remitente | Povinný |
idgroup | Identifikátor cílové skupiny | Povinný |
E-mailová zpráva k odeslání | Povinný | |
scheduledatetime | Datum a čas dodání ve formátu rrrr-mm-dd hh:mm:ss | Volitelný |
output | Výstupní formát výsledku | Volitelný |
Při zadávání žádostí obdržíte následující pole:
- status
-
výsledek (pokud status = úspěch), zde obdržíte následující hodnoty:
- id
- count
- credits
-
destinations
- messageid
- destination
- chyba (pokud status = chyba), zde obdržíte kód chyby
Možné chybové kódy jsou uvedeny níže
Kód | Popis |
---|---|
MISSING_USER | Uživatel nebo e-mail nejsou zahrnuty |
MISSING_PASSWORD | Heslo není zahrnuto |
MISSING_CLASS | Třída není zahrnuta |
MISSING_METHOD | Metoda není zahrnuta |
MISSING_COMPULSORY_PARAM | Povinný parametr není zahrnut |
INCORRECT_USER_PASSWORD | Nesprávný uživatel nebo heslo |
INCORRECT_CLASS | Nesprávná třída |
INCORRECT_METHOD | Nesprávná metoda |
NOT_ACCESS_TO_GROUP | Do uvedené skupiny nemáte povolení |
NO_CREDITS | Váš zůstatek je nedostatečný |
Parametry:
- class : email
- method : sendemailtogroup
- user : user
- password : password
- subject : Afilnet - Test email
- idgroup : 1
- email : Afilnet - Test email
- scheduledatetime :
- output :
Žádost:
https://www.afilnet.com/api/http/?class=email&method=sendemailtogroup&user=user&password=password&subject=Afilnet - Test email&idgroup=1&email=Afilnet - Test email&scheduledatetime=&output=