Send e-mail fra skabelon med Python
Send en e-mail-skabelon til en e-mail-adresse ved hjælp af Python
Python : API-DOKUMENTATION
- Opret gruppe med Python
- Hent gruppe feltliste med Python
- Føj et felt til en gruppe med Python
- Slet et felt fra en gruppe med Python
- Slet en kontakt fra en gruppe
- At give land en e-gruppe med Python
- Hent gruppekontaktliste med Python
- Føj kontakt til en gruppe med Python
- Rediger kontakt for en gruppe med Python
- Slet kontakt fra en gruppe med Python
Send e-mail fra skabelon med Python
import urllib2
afilnet_class="email"
afilnet_method="sendemailfromtemplate"
afilnet_user="user"
afilnet_password="password"
afilnet_to="34600000000"
afilnet_idtemplate="1000"
afilnet_params="mobile:123456789,name:test+name"
afilnet_scheduledatetime=""
afilnet_output=""
# Create an URL request
sUrl = "https://www.afilnet.com/api/http/?class="+afilnet_class+"&method="+afilnet_method+"&user="+afilnet_user+"&password="+afilnet_password+"&to="+afilnet_to+"&idtemplate="+afilnet_idtemplate+"¶ms="+afilnet_params+"&scheduledatetime="+afilnet_scheduledatetime+"&output="+afilnet_output
result = urllib2.urlopen(sUrl).read()
from urllib.request import urlopen
from urllib.parse import urlencode
afilnet_class="email"
afilnet_method="sendemailfromtemplate"
afilnet_user="user"
afilnet_password="password"
afilnet_to="34600000000"
afilnet_idtemplate="1000"
afilnet_params="mobile:123456789,name:test+name"
afilnet_scheduledatetime=""
afilnet_output=""
# Create an URL request
sUrl = "https://www.afilnet.com/api/http/"
data = urlencode({"class": afilnet_class,"method": afilnet_method,"user": afilnet_user,"password": afilnet_password,"to": afilnet_to,"idtemplate": afilnet_idtemplate,"params": afilnet_params,"scheduledatetime": afilnet_scheduledatetime,"output": afilnet_output}).encode("utf-8")
result = urlopen(sUrl, data).read()
print(result)
import requests
afilnet_class="email"
afilnet_method="sendemailfromtemplate"
afilnet_user="user"
afilnet_password="password"
afilnet_to="34600000000"
afilnet_idtemplate="1000"
afilnet_params="mobile:123456789,name:test+name"
afilnet_scheduledatetime=""
afilnet_output=""
# Create an URL request
sUrl = "https://www.afilnet.com/api/basic/?class="+afilnet_class+"&method="+afilnet_method+"&to="+afilnet_to+"&idtemplate="+afilnet_idtemplate+"¶ms="+afilnet_params+"&scheduledatetime="+afilnet_scheduledatetime+"&output="+afilnet_output
result = requests.get(sUrl,auth=requests.auth.HTTPBasicAuth(afilnet_user,afilnet_password))
print(result.text)
Parameter | Beskrivelse | Obligatorisk / valgfri |
---|---|---|
class=email | Klasse anmodet: Klasse, som anmodningen indgives til | Obligatorisk |
method=sendemailfromtemplate | Anmodet om klassemetode: Metode for den klasse, som anmodningen indgives til | Obligatorisk |
user | Bruger og e-mail på din Afilnet-konto | Obligatorisk |
password | Adgangskode til din Afilnet-konto | Obligatorisk |
to | Destination e-mail | Obligatorisk |
idtemplate | Skabelonidentifikator | Obligatorisk |
params |
Parametre, der skal erstattes i skabelonen til tilpasning (< |
Valgfri |
scheduledatetime | Leveringsdato og -tid i åååå-mm-dd tt: mm: ss-format | Valgfri |
output | Outputformat for resultatet | Valgfri |
Når du fremsætter anmodninger, modtager du følgende felter:
- status
-
resultat (hvis status = succes), her vil du modtage følgende værdier:
- messageid
- credits
- fejl (hvis status = fejl), her vil du modtage fejlkoden
De mulige fejlkoder er vist nedenfor
Kode | Beskrivelse |
---|---|
MISSING_USER | Bruger eller e-mail er ikke inkluderet |
MISSING_PASSWORD | Adgangskode er ikke inkluderet |
MISSING_CLASS | Klasse ikke inkluderet |
MISSING_METHOD | Metode er ikke inkluderet |
MISSING_COMPULSORY_PARAM | Obligatorisk parameter ikke inkluderet |
INCORRECT_USER_PASSWORD | Forkert bruger eller adgangskode |
INCORRECT_CLASS | Forkert klasse |
INCORRECT_METHOD | Forkert metode |
NO_ROUTE_AVAILABLE | Der er ingen tilgængelige stier til den angivne destination |
NO_CREDITS | Din balance er utilstrækkelig |
NOT_ACCESS_TO_TEMPLATE | Du har ikke adgang til den valgte skabelon |
Parametre:
- class : email
- method : sendemailfromtemplate
- user : user
- password : password
- to : 34600000000
- idtemplate : 1000
- params : mobile:123456789,name:test+name
- scheduledatetime :
- output :
Anmodning:
https://www.afilnet.com/api/http/?class=email&method=sendemailfromtemplate&user=user&password=password&to=34600000000&idtemplate=1000¶ms=mobile:123456789,name:test+name&scheduledatetime=&output=