本文整理汇总了Java中com.twilio.sdk.TwilioRestException类的典型用法代码示例。如果您正苦于以下问题:Java TwilioRestException类的具体用法?Java TwilioRestException怎么用?Java TwilioRestException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TwilioRestException类属于com.twilio.sdk包,在下文中一共展示了TwilioRestException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendClientText
import com.twilio.sdk.TwilioRestException; //导入依赖的package包/类
public static boolean sendClientText(String recipient, String from, String message) throws TwilioRestException, InterruptedException {
if (recipient != null && message != null && from != null && !from.isEmpty() && !recipient.isEmpty() && !message.isEmpty()) {
TwilioRestClient client = new TwilioRestClient(accountSID, authToken);
recipient = recipient.contains("+1") ? recipient : "+1" + recipient;
from = from.contains("+1") ? from : "+1" + from;
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("Body", message));
params.add(new BasicNameValuePair("To", recipient));
params.add(new BasicNameValuePair("From", from));
MessageFactory messageFactory = client.getAccount().getMessageFactory();
Message text = messageFactory.create(params);
if (text.getErrorCode() != null) {
return false;
}
return true;
}
return false;
}
示例2: main
import com.twilio.sdk.TwilioRestException; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Build a filter for the CallList
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("Url", "http://www.example.com/sipdial.xml"));
params.add(new BasicNameValuePair("To", "sip:[email protected]"));
params.add(new BasicNameValuePair("From", "Jack"));
params.add(new BasicNameValuePair("SipAuthPassword", "secret"));
params.add(new BasicNameValuePair("SipAuthUsername", "jack"));
CallFactory callFactory = client.getAccount().getCallFactory();
Call call = callFactory.create(params);
System.out.println(call.getSid());
}
示例3: main
import com.twilio.sdk.TwilioRestException; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Build a filter for the ConferenceList
Map<String, String> params = new HashMap<String, String>();
params.put("Status", "in-progress");
params.put("FriendlyName", "MyRoom");
ConferenceList conferences = client.getAccount().getConferences(params);
// Loop over conferences and print out a property for each one.
for (Conference conference : conferences) {
System.out.println(conference.getStatus());
}
}
示例4: main
import com.twilio.sdk.TwilioRestException; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Build a filter for the NotificationList
Map<String, String> params = new HashMap<String, String>();
params.put("MessageDate>", "2009-07-06");
params.put("MessageDate<", "2009-07-08");
params.put("Log", "1");
NotificationList notifications = client.getAccount().getNotifications(params);
// Loop over notifications and print out a property for each one.
for (Notification notification : notifications) {
System.out.println(notification.getRequestUrl());
}
}
示例5: main
import com.twilio.sdk.TwilioRestException; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);
WorkflowStatistics statistics = client.getWorkflowStatistics(WORKSPACE_SID, WORKFLOW_SID);
System.out.println("Avg Task Acceptance Time: "+statistics.getAverageTaskAcceptanceTime());
System.out.println("Tasks Entered: "+statistics.getTasksEntered());
System.out.println("Pending Tasks: "+statistics.getPendingTasks());
System.out.println("Assigned Tasks: "+statistics.getAssignedTasks());
//alternatively
Workflow workflow = client.getWorkflow(WORKSPACE_SID, WORKFLOW_SID);
statistics = workflow.getStatistics();
System.out.println("Avg Task Acceptance Time: "+statistics.getAverageTaskAcceptanceTime());
System.out.println("Tasks Entered: "+statistics.getTasksEntered());
System.out.println("Pending Tasks: "+statistics.getPendingTasks());
System.out.println("Assigned Tasks: "+statistics.getAssignedTasks());
}
示例6: main
import com.twilio.sdk.TwilioRestException; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Build a filter for the AvailablePhoneNumberList
Map<String, String> params = new HashMap<String, String>();
params.put("VoiceEnabled", "true");
AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "GB", "Local");
List<AvailablePhoneNumber> list = numbers.getPageData();
// Purchase the first number on the list.
List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
}
示例7: main
import com.twilio.sdk.TwilioRestException; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Build a filter for the AvailablePhoneNumberList
Map<String, String> params = new HashMap<String, String>();
params.put("AreaCode", "800");
params.put("Contains", "KYLO");
AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "US", "TollFree");
List<AvailablePhoneNumber> list = numbers.getPageData();
// Purchase the first number on the list.
List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
}
示例8: main
import com.twilio.sdk.TwilioRestException; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Build a filter for the ConferenceList
Map<String, String> params = new HashMap<String, String>();
params.put("Status", "in-progress");
params.put("DateCreated>", "2009-07-06");
ConferenceList conferences = client.getAccount().getConferences(params);
// Loop over conferences and print out a property for each one.
for (Conference conference : conferences) {
System.out.println(conference.getStatus());
}
}
示例9: main
import com.twilio.sdk.TwilioRestException; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);
Map<String, String> params = new HashMap<String, String>();
params.put("FriendlyName", "Support Worker 1");
params.put("Attributes", "{\"type\":\"support\"}");
Worker worker = client.createWorker(WORKSPACE_SID, params);
System.out.println(worker.getFriendlyName());
// alternatively
Workspace workspace = client.getWorkspace(WORKSPACE_SID);
worker = workspace.createWorker(params);
System.out.println(worker.getFriendlyName());
// alternate #2 using attributes as a map
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("type", "support");
worker = workspace.createWorker("Support Worker 1", attributes, null);
System.out.println(worker.getFriendlyName());
}
示例10: main
import com.twilio.sdk.TwilioRestException; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Build a filter for the CallList
Map<String, String> params = new HashMap<String, String>();
params.put("Status", "completed");
params.put("StartTime>", "2009-07-06");
CallList calls = client.getAccount().getCalls(params);
// Loop over calls and print out a property for each one.
for (Call call : calls) {
System.out.println(call.getTo());
}
}
示例11: main
import com.twilio.sdk.TwilioRestException; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException, ParseException {
TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);
Map<String, String> params = new HashMap<String, String>();
params.put("WorkflowSid", WORKFLOW_SID);
params.put("Attributes", "{\"type\":\"support\"}");
Task task = client.createTask(WORKSPACE_SID, params);
System.out.println(task.getAttributes());
// alternatively
Workspace workspace = client.getWorkspace(WORKSPACE_SID);
task = workspace.createTask(params);
System.out.println(task.getAttributes());
// alternate #2 using attributes as a map
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("type", "support");
task = workspace.createTask(WORKFLOW_SID, attributes, null, null);
System.out.println(task.parseAttributes().get("type"));
}
示例12: main
import com.twilio.sdk.TwilioRestException; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);
Worker worker = client.getWorker(WORKSPACE_SID, WORKER_SID);
Map<String, String> params = new HashMap<String, String>();
params.put("Attributes", "{\"type\":\"support\"}");
worker.update(params);
//alternatively
Workspace workspace = client.getWorkspace(WORKSPACE_SID);
worker = workspace.getWorker(WORKER_SID);
worker.update(params);
// alternate #2 using attributes as a map
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("type", "support");
worker.update(attributes, null, null);
}
示例13: service
import com.twilio.sdk.TwilioRestException; //导入依赖的package包/类
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
String uniqueId = request.getParameter("id");
// Lookup variable `uniqueId` in a database to find messageSid
String messageSid = "SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
Map<String, String> postParams = new HashMap<>();
postParams.put("Outcome", "confirmed");
try {
client.request("/2010-04-01/Accounts/" + ACCOUNT_SID + "/Messages/" + sid + "/Feedback.json",
"POST", postParams);
} catch (TwilioRestException e) {
e.printStackTrace();
}
}
示例14: getNewNumber
import com.twilio.sdk.TwilioRestException; //导入依赖的package包/类
public static String getNewNumber() throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(accountSID, authToken);
// Build a filter for the AvailablePhoneNumberList
Map<String, String> params = new HashMap<String, String>();
params.put("SmsEnabled", "true");
AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "US", "Local");
List<AvailablePhoneNumber> list = numbers.getPageData();
// Purchase the first number in the list.
List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
purchaseParams.add(new BasicNameValuePair("SmsUrl", "http://platform.workamerica.co/TwilioReceiverServlet"));
return client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams).getPhoneNumber().substring(2);
}
示例15: setUp
import com.twilio.sdk.TwilioRestException; //导入依赖的package包/类
@BeforeClass
public void setUp() throws TwilioRestException {
HashMap<String, String> candidateMap = new HashMap<String, String>();
candidateMap.put("firstName", "John");
candidateMap.put("lastName", "Smith");
candidate = CandidatePersistence.createCandidate(candidateMap);
HashMap<String, String> clientMap = new HashMap<String, String>();
clientMap.put("firstName", "Test");
clientMap.put("lastName", "Testy");
client = ClientPersistence.createClient(clientMap);
}