OTP s C Sharp
Vygenerujte token OTP (jednorázové heslo) pomocí C Sharp
C Sharp : DOKUMENTACE API
- Vytvořit skupinu pomocí C Sharp
- Seznam skupinových polí s C Sharp
- Přidejte pole do skupiny s C Sharp
- Odstranění pole ze skupiny s C Sharp
- Odstranění kontaktu ze skupiny
- Přiřazení země do skupiny s C Sharp
- Seznam skupinových kontaktů s C Sharp
- Přidejte kontakt do skupiny s C Sharp
- Upravit kontakt skupiny pomocí C Sharp
- Smazat kontakt skupiny s C Sharp
- Získejte seznam aktivních chatovacích kanálů s jazykem C Sharp
- Odeslat zprávu prostřednictvím chatu s jazykem C Sharp
- Odeslat soubor prostřednictvím chatu s jazykem C Sharp
- Získejte seznam konverzací v chatu s jazykem C Sharp
- Získejte seznam zpráv z chatu s jazykem C Sharp
- Získejte seznam nepřečtených zpráv z chatu s jazykem C Sharp
OTP s C Sharp
String afilnet_class="otp";
String afilnet_method="generateotp";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_type="number";
String afilnet_destination="34600000000";
String afilnet_time="1";
String afilnet_timetype="days";
String afilnet_length="6";
String afilnet_otpformat="all";
String afilnet_output="";
// Create an URL request
WebRequest request = WebRequest.Create("https://www.afilnet.com/api/http/?class="+afilnet_class+"&method="+afilnet_method+"&user="+afilnet_user+"&password="+afilnet_password+"&type="+afilnet_type+"&destination="+afilnet_destination+"&time="+afilnet_time+"&timetype="+afilnet_timetype+"&length="+afilnet_length+"&otpformat="+afilnet_otpformat+"&output="+afilnet_output);
// Get the response
WebResponse response = request.GetResponse ();
// Get the stream returned by the server
Stream dataStream = response.GetResponseStream();
// Open the stream
StreamReader reader = new StreamReader (dataStream);
// Read the Response
String result = reader.ReadToEnd ();
// Asign vars
var data = new NameValueCollection();
data["class"] = "otp";
data["method"] = "generateotp";
data["user"] = "user";
data["password"] = "password";
data["type"] = "number";
data["destination"] = "34600000000";
data["time"] = "1";
data["timetype"] = "days";
data["length"] = "6";
data["otpformat"] = "all";
data["output"] = "";
// Create Web client
var wb = new WebClient();
// Execute POST petition
var response = wb.UploadValues("https://www.afilnet.com/api/http/", "POST", data);
// Get response
string responseString = Encoding.UTF8.GetString(response);
// Asign vars
var data = new NameValueCollection();
data["class"] = "otp";
data["method"] = "generateotp";
data["type"] = "number";
data["destination"] = "34600000000";
data["time"] = "1";
data["timetype"] = "days";
data["length"] = "6";
data["otpformat"] = "all";
data["output"] = "";
// Create Web client
var wb = new WebClient { Credentials = new NetworkCredential("user", "password") };
// Execute POST petition
var response = wb.UploadValues("https://www.afilnet.com/api/http/", "POST", data);
// Get response
string responseString = Encoding.UTF8.GetString(response);
String afilnet_class="otp";
String afilnet_method="generateotp";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_type="number";
String afilnet_destination="34600000000";
String afilnet_time="1";
String afilnet_timetype="days";
String afilnet_length="6";
String afilnet_otpformat="all";
String afilnet_output="";
// Allow SSL/TLS config
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// We create the webservice instance (Register Web Service first in project)
var service = new WebService.ApplicationServicesPortTypeClient();
// Call to WebService method
String response = service.call(afilnet_user, afilnet_password, afilnet_class, afilnet_method, "{\"type\":\""+afilnet_type+"\",\"destination\":\""+afilnet_destination+"\",\"time\":\""+afilnet_time+"\",\"timetype\":\""+afilnet_timetype+"\",\"length\":\""+afilnet_length+"\",\"otpformat\":\""+afilnet_otpformat+"\",\"output\":\""+afilnet_output+"\"}");
Parametr | Popis | Povinné / Nepovinné |
---|---|---|
class=otp | Požadovaná třída: Třída, na kterou je žádost podána | Povinný |
method=generateotp | 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ý |
type | Typ skupiny (e-mail nebo mobilní) | Povinný |
destination | Mobilní číslo nebo cílový e-mail | Povinný |
time | Počet dní, týdnů, měsíců nebo let | Volitelný |
timetype | Druh času (Možná hodnota: dny, týdny, měsíce nebo roky) | Volitelný |
length | Délka hesla, které se má vygenerovat | Volitelný |
otpformat | Formát hesla pro generování, pokud obsahuje všechny znaky, pouze čísla nebo pouze písmena (všechna, čísla, písmena) | 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:
- Nebudou vám zasílány žádné další hodnoty
- 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 |
INCORRECT_TIME_TYPE | Nesprávný typ času (možné hodnoty: dny, týdny, měsíce nebo roky) |
INCORRECT_TYPE | Nesprávný typ. Typ musí být mobilní nebo e-mail |
INCORRECT_FORMAT | ERROR_INCORRECT_FORMAT |
INCORRECT_OTP_FORMAT | ERROR_INCORRECT_OTP_FORMAT |
Parametry:
- class : otp
- method : generateotp
- user : user
- password : password
- type : number
- destination : 34600000000
- time : 1
- timetype : days
- length : 6
- otpformat : all
- output :
Žádost:
https://www.afilnet.com/api/http/?class=otp&method=generateotp&user=user&password=password&type=number&destination=34600000000&time=1&timetype=days&length=6&otpformat=all&output=