Send SMS Method:
URL:
https://sms.alis.ir/sms/
Method name:
Send
Input parameters:
# | Name | Type |
---|---|---|
1 | UserName | string |
2 | Password | string |
3 | MobileNumber | string |
4 | Message | string |
Output parameters:
This methode returns a json string that contains these parameters:
# | Name | Type |
---|---|---|
1 | ResultValue | string |
2 | ResultMessage | string |
C# Example
public static async Task<T>PostAsync<T>(string BaseUrl, string EndpointName, object InputParams) { try { var client = new HttpClient(); client.BaseAddress = new Uri(BaseUrl); var inputjason = JsonConvert.SerializeObject(InputParams); var content = new StringContent(inputjason, Encoding.UTF8, "application/json"); var response = await client.PostAsync(EndpointName, content); if (response.StatusCode == HttpStatusCode.OK) { var json = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject<T>(json); return result; } return default(T); } catch (Exception ex) { Console.WriteLine(ex.Message); return default(T); } } //--------------------------------------------------------------------------------------------------------------- public class ResultEntity { public bool ResultValue { get; set; } public string ResultMessage { get; set; } } //--------------------------------------------------------------------------------------------------------------- public class InputEntity { public string UserName { get; set; } public string Password { get; set; } public string MobileNumber { get; set; } public string Message { get; set; } } //--------------------------------------------------------------------------------------------------------------- public static class CallExternalServices { public static ResultEntity SendSms(string MobileNumber, string Message) { string url = "http://sms.alis.ir/sms"; <------------------- Enter URL here InputEntity inputEntity = new InputEntity() { UserName = "username", <------------------- Enter UserName here Password = "password", <------------------- Enter Password here MobileNumber = MobileNumber, Message = Message }; ResultEntity response = PostAsync<ResultEntity>(url, "Send", inputEntity).GetAwaiter().GetResult(); return response; } }