public void CampaignSms(CampaignDto model) { // var phoneNumbers = from p in _db.Donors //select new { p.Phone }; string clientId = _config.GetValue <string>("Sms:ClientId"); string clientSecret = _config.GetValue <string>("Sms:ClientSecret"); StringBuilder builder = new StringBuilder(); builder.Append("Donor Trace Campaign"); builder.AppendLine(); builder.Append("Organization: " + " " + model.Organization); builder.AppendLine(); builder.Append("Description: " + " " + model.Description); builder.AppendLine(); builder.Append("Location: " + " " + model.Location); builder.AppendLine(); builder.Append("Date: " + " " + model.EventDate); var host = new ApiHost(new BasicAuth(clientId, clientSecret)); var messageApi = new MessagingApi(host); // foreach (var p in phoneNumbers) // { MessageResponse msg = messageApi.SendQuickMessage("Donor Trace", "0242229571", builder.ToString(), true); //} // return Ok(); }
public void HubtrlMessage(string num, string info) { const string clientId = "eesuojtu"; const string clientSecret = "shfgzcjx "; //try //{ var host = new ApiHost(new BasicAuth(clientId, clientSecret)); var messageApi = new MessagingApi(host); MessageResponse msg = messageApi.SendQuickMessage("COCA-COLA", num, info, true); Console.WriteLine(msg.Status); //} //catch (Exception e) //{ // if (e.GetType() == typeof(HttpRequestException)) // { // var ex = e as HttpRequestException; // if (ex != null && ex.HttpResponse != null) // { // Console.WriteLine("Error Status Code " + ex.HttpResponse.Status); // } // } // throw; //} //Console.ReadKey(); }
private static void Main(string[] args) { const string clientId = "clientId"; const string clientSecret = "clientSecret"; try { var host = new ApiHost(new BasicAuth(clientId, clientSecret)); var messageApi = new MessagingApi(host); MessageResponse msg = messageApi.SendQuickMessage("DevUniverse", "+233207110652", "Welcome to planet Hubtel!", true); Console.WriteLine(msg.Status); } catch (Exception e) { if (e.GetType() == typeof(HttpRequestException)) { var ex = e as HttpRequestException; if (ex != null && ex.HttpResponse != null) { Console.WriteLine("Error Status Code " + ex.HttpResponse.Status); } } throw; } Console.ReadKey(); }
private static void Main(string[] args) { const string clientId = "hqikydyh"; const string clientSecret = "kakdxpvd"; try { var host = new ApiHost(new BasicAuth(clientId, clientSecret)); var messageApi = new MessagingApi(host); MessageResponse msg = messageApi.SendQuickMessage("Arsene", "+233247063817", "Hello Big Bro!", true); Console.WriteLine(msg.Status); } catch (Exception e) { if (e.GetType() == typeof(HttpRequestException)) { var ex = e as HttpRequestException; if (ex != null && ex.HttpResponse != null) { Console.WriteLine("Error Status Code " + ex.HttpResponse.Status); } } throw; } Console.ReadKey(); }
private static void Main(string[] args) { const string clientId = "mcjntyvj"; const string clientSecret = "csidlcvn"; try { var host = new ApiHost(new BasicAuth(clientId, clientSecret)); var messageApi = new MessagingApi(host); MessageResponse msg = messageApi.SendQuickMessage("BPCI", "+233274323816", "Welcome to BPCI HQ!", false); Console.WriteLine(msg.Status); } catch (Exception e) { if (e.GetType() == typeof(HttpRequestException)) { var ex = e as HttpRequestException; if (ex != null && ex.HttpResponse != null) { Console.WriteLine("Error Status Code " + ex.HttpResponse.Status); } } throw; } Console.ReadKey(); }
public void SendBulkSMS() { var host = new ApiHost(new BasicAuth(ClientCredentials.GetClientId(), ClientCredentials.GetSecret())); var messageApi = new MessagingApi(host); MessageResponse msg = messageApi.SendQuickMessage(MessageId, Phone, MessageBody, RegisteredDelivery); Console.WriteLine("Message Sent Successfully to " + Phone); }
public int doSMSJob() { string formattedPhone = ""; var host = new ApiHost(new BasicAuth(ClientCredentials.GetClientId(), ClientCredentials.GetSecret())); if (MessageLogger.EnableLogging == true) { MessageLogger.LogStatus(MessageLogger.LogPath, "Starting New Batch............................................................."); MessageLogger.LogStatus(MessageLogger.LogPath, "Establishing Server Connection"); } var messageApi = new MessagingApi(host); foreach (var phone in Phone.PhoneNumbers) { if (MessageLogger.EnableLogging == true) { MessageLogger.LogStatus(MessageLogger.LogPath, "Sending to........ " + phone); } //Remove 0 and add +233 to the beginning of the phone numbers if (Phone.FormatLocal == true) { formattedPhone = Phone.Validate(phone); } //checking the Ghanaian standard mobile length if (phone.Length < 10) { // log unsent message to outBox MessageLogger.logOutbox(formattedPhone, "Rejected due to length < 10"); continue; } else { try { MessageResponse msge = messageApi.SendQuickMessage(MessageId, formattedPhone, MessageBody, RegisteredDelivery); MessageLogger.logSent(formattedPhone, "Successful"); } catch (Exception e) { MessageLogger.logOutbox(formattedPhone, "rejected due to server error !"); //pass control to the next iteration of the enclosing foreach statement continue; } } } //returns number of sent >1 when successful return(MessageLogger.sent.Count); }
public void SendSms(OfficerDto officer) { string clientId = _config.GetValue <string>("Sms:ClientId"); string clientSecret = _config.GetValue <string>("Sms:ClientSecret"); StringBuilder builder = new StringBuilder(); builder.Append("You have been registered on the Donor Trace Mobile App"); builder.AppendLine(); builder.Append("Username: "******" " + officer.UserName); builder.AppendLine(); builder.Append("Password: "******" " + officer.Password); var host = new ApiHost(new BasicAuth(clientId, clientSecret)); var messageApi = new MessagingApi(host); MessageResponse msg = messageApi.SendQuickMessage("Donor Trace", officer.ContactNo, builder.ToString(), true); }
public async Task <IActionResult> Sms(SmsDto sms) { string clientId = _config.GetValue <string>("Sms:ClientId"); string clientSecret = _config.GetValue <string>("Sms:ClientSecret"); StringBuilder builder = new StringBuilder(); builder.Append("You have been registered on the Donor Trace Mobile App"); var host = new ApiHost(new BasicAuth(clientId, clientSecret)); var messageApi = new MessagingApi(host); MessageResponse msg = messageApi.SendQuickMessage("Donor Trace", sms.To, builder.ToString(), false); return(Ok(msg.Status)); }