The following example demonstrates the use of the Text service instead of the
Broadcast service for sending batches of texts.
Note that you cannot send a message from a number to itself. Although the operation
may succeed, the text will not be delivered.
var client = new CallfireClient("api-login", "api-password", CallfireClients.Rest);
var textClient = client.Text;
var textBroadcastConfig = new CfTextBroadcastConfig();
textBroadcastConfig.FromNumber = "15551231234";
textBroadcastConfig.Message = "Test API Text";
var toNumber = new CfToNumber();
toNumber.Value = "15551231235";
var sendText = new CfSendText();
sendText.TextBroadcastConfig = textBroadcastConfig;
sendText.ToNumber = new [] { toNumber };
var id = textClient.SendText(SendText);var client = new CallfireClient("api-login", "api-password", CallfireClients.Rest);
var textClient = client.Text;
var textBroadcastConfig = new CfTextBroadcastConfig();
textBroadcastConfig.FromNumber = "15551231234";
textBroadcastConfig.Message = "Test API Text";
var toNumber_1 = new CfToNumber();
toNumber_1.Value = "15551231235";
var toNumber_2 = new CfToNumber();
toNumber_2.Value = "15551231236";
var toNumber_3 = new CfToNumber();
toNumber_3.Value = "15551231237";
var toNumber_4 = new CfToNumber();
toNumber_4.Value = "15551231238";
var sendText = new CfSendText();
sendText.TextBroadcastConfig = textBroadcastConfig;
sendText.ToNumber = new [] { toNumber_1, toNumber_2, toNumber_3, toNumber_4 };
var id = textClient.SendText(SendText);var client = new CallfireClient("api-login", "api-password", CallfireClients.Rest);
var textClient = client.Text;
var textBroadcastConfig = new CfTextBroadcastConfig();
textBroadcastConfig.FromNumber = "15551231234";
textBroadcastConfig.Message = "Test API Text";
var toNumber = new CfToNumber();
toNumber.Value = "15551231235";
var sendText = new CfSendText();
sendText.TextBroadcastConfig = textBroadcastConfig;
sendText.ToNumber = new [] { toNumber };
//Note: label values with spaces can't be used for REST api calls, only for SOAP (limitation)
sendText.Labels = new string[] { "Test_Label_1", "Test_Label_2" };
var id = textClient.SendText(SendText);var client = new CallfireClient("api-login", "api-password", CallfireClients.Rest);
var textClient = client.Text;
var cfActionQuery = new CfActionQuery();
cfActionQuery.toNumber = "15551231234";
var cfTextQueryResult = textClient.QueryTexts(cfActionQuery);
if (cfTextQueryResult.Text != null)
{
var textList = new string[cfTextQueryResult.Text.Count()];
for (var i = 0; i < cfTextQueryResult.Text.Count(); i++)
{
var cfText = cfTextQueryResult.Text[i];
textList[i] = string.Format("Created: {0} FromNumber: {1} Message: {2}",
cfText.Created.ToString(), cfText.FromNumber, cfText.Message);
}
}##Create Auto-Reply for Keyword Texted to CallFire Short-code 67076
var client = new CallfireClient("api-login", "api-password", CallfireClients.Rest);
var textClient = client.Text;
var cfAutoReply = new CfAutoReply();
cfAutoReply.Number = "67076";
cfAutoReply.Keyword = "Keyword";
cfAutoReply.Message = "Auto-reply message";
var cfCreateAutoReply = new CfCreateAutoReply();
cfCreateAutoReply.CfAutoReply = cfAutoReply;
var id = textClient.CreateAutoReply(cfCreateAutoReply)