本文整理汇总了Java中com.twilio.sdk.resource.instance.Account类的典型用法代码示例。如果您正苦于以下问题:Java Account类的具体用法?Java Account怎么用?Java Account使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Account类属于com.twilio.sdk.resource.instance包,在下文中一共展示了Account类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: service
import com.twilio.sdk.resource.instance.Account; //导入依赖的package包/类
@Override
public void service(HttpServletRequest req, HttpServletResponse resp) throws IOException,
ServletException {
final String twilioAccountSid = System.getenv("TWILIO_ACCOUNT_SID");
final String twilioAuthToken = System.getenv("TWILIO_AUTH_TOKEN");
final String twilioNumber = System.getenv("TWILIO_NUMBER");
final String toNumber = (String) req.getParameter("to");
if (toNumber == null) {
resp.getWriter()
.print("Please provide the number to message in the \"to\" query string parameter.");
return;
}
TwilioRestClient client = new TwilioRestClient(twilioAccountSid, twilioAuthToken);
Account account = client.getAccount();
MessageFactory messageFactory = account.getMessageFactory();
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("To", toNumber));
params.add(new BasicNameValuePair("From", twilioNumber));
params.add(new BasicNameValuePair("Body", "Hello from Twilio!"));
try {
Message sms = messageFactory.create(params);
resp.getWriter().print(sms.getBody());
} catch (TwilioRestException e) {
throw new ServletException("Twilio error", e);
}
}
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:27,代码来源:SendSmsServlet.java
示例2: service
import com.twilio.sdk.resource.instance.Account; //导入依赖的package包/类
@Override
public void service(HttpServletRequest req, HttpServletResponse resp)
throws IOException, ServletException {
final String twilioAccountSid = System.getenv("TWILIO_ACCOUNT_SID");
final String twilioAuthToken = System.getenv("TWILIO_AUTH_TOKEN");
final String twilioNumber = System.getenv("TWILIO_NUMBER");
final String toNumber = (String) req.getParameter("to");
if (toNumber == null) {
resp.getWriter()
.print("Please provide the number to message in the \"to\" query string parameter.");
return;
}
TwilioRestClient client = new TwilioRestClient(twilioAccountSid, twilioAuthToken);
Account account = client.getAccount();
MessageFactory messageFactory = account.getMessageFactory();
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("To", toNumber));
params.add(new BasicNameValuePair("From", twilioNumber));
params.add(new BasicNameValuePair("Body", "Hello from Twilio!"));
try {
Message sms = messageFactory.create(params);
resp.getWriter().print(sms.getBody());
} catch (TwilioRestException e) {
throw new ServletException("Twilio error", e);
}
}
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:27,代码来源:SendSmsServlet.java
示例3: makeCall
import com.twilio.sdk.resource.instance.Account; //导入依赖的package包/类
public boolean makeCall(String phoneNumber, String code, String lang) {
if (canRun()) {
final Account account = TWILIO_CLIENT.getAccount(); // Make a call
CallFactory callFactory = account.getCallFactory();
Map<String, String> callParams = new HashMap<String, String>();
callParams.put("To", phoneNumber);
callParams.put("From", TWILIO_FROM_NUMBER);
callParams.put("Url", CoreConfiguration.getConfiguration().applicationUrl()
+ "/external/partyContactValidation.do?method=validatePhone&code=" + code + "&lang=" + lang);
try {
callFactory.create(callParams);
return true;
} catch (TwilioRestException e) {
logger.error("Error makeCall: " + e.getMessage(), e);
return false;
}
} else {
logger.info("Call to >" + phoneNumber + "<: Bem-vindo ao sistema Fénix. Introduza o código " + code + " . Obrigado!");
return true;
}
}
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:22,代码来源:PhoneValidationUtils.java
示例4: main
import com.twilio.sdk.resource.instance.Account; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
Account mainAccount = client.getAccount();
CallFactory callFactory = mainAccount.getCallFactory();
Map<String, String> callParams = new HashMap<String, String>();
final String toNumber = "4153263626";
final String fromNumber = "3109862198";
callParams.put("To", toNumber); // Replace with your phone number
callParams.put("From", fromNumber); // Replace with a Twilio number
callParams.put("Url", URL);
// callParams.put("Url", "http://demo.twilio.com/welcome/voice?fromNumber="+toNumber);
// Make the call
Call call = callFactory.create(callParams);
// Print the call SID (a 32 digit hex like CA123..)
System.out.println("sid - " + call.getSid());
System.out.println("dir - " + call.getDirection());
System.out.println("fro - " + call.getFrom());
System.out.println("answered by - " + call.getAnsweredBy());
System.out.println("price" + call.getPrice());
System.out.println("status - " + call.getStatus());
System.out.println("to - " + call.getTo());
System.out.println("callerName " + call.getCallerName());
System.out.println("start time - " + call.getStartTime());
System.out.println("duration - " + call.getDuration());
}
开发者ID:ongoingjourney,项目名称:MyExperiments,代码行数:26,代码来源:MakeCall.java
示例5: main
import com.twilio.sdk.resource.instance.Account; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
Account account = client.getAccount("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
// Build a filter for the AccountList
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("Status", "closed"));
account.update(params);
}
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:13,代码来源:instance-post-example-3.6.x.java
示例6: main
import com.twilio.sdk.resource.instance.Account; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
Account account = client.getAccount("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
// Build a filter for the AccountList
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("Status", "active"));
account.update(params);
}
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:13,代码来源:instance-post-example-2.6.x.java
示例7: main
import com.twilio.sdk.resource.instance.Account; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
Account account = client.getAccount("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
System.out.println(account.getDateCreated());
}
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:10,代码来源:instance-get-example-1.6.x.java
示例8: main
import com.twilio.sdk.resource.instance.Account; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
Account account = client.getAccount("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
// Build a filter for the AccountList
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("Status", "suspended"));
account.update(params);
}
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:13,代码来源:instance-post-example-1.6.x.java
示例9: main
import com.twilio.sdk.resource.instance.Account; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
Account account = client.getAccount("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
System.out.println(account.getStatus());
}
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:10,代码来源:listing-subaccounts-example-1.6.x.java
示例10: main
import com.twilio.sdk.resource.instance.Account; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Build a filter for the AccountList
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("FriendlyName", "Submarine"));
AccountFactory accountFactory = client.getAccountFactory();
Account account = accountFactory.create(params);
System.out.println(account.getSid());
}
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:13,代码来源:creating-subaccounts-example-1.6.x.java
示例11: sendSms
import com.twilio.sdk.resource.instance.Account; //导入依赖的package包/类
public static Message sendSms(final String phoneNumber, final String smsMessage)
throws NumberParseException, IllegalArgumentException, TwilioRestException {
checkPhoneNumber(phoneNumber);
checkSmsMessage(smsMessage);
final String accountSid = ApiKeysUtils.getApiKey("twilioAccountSid");
final String authToken = ApiKeysUtils.getApiKey("twilioAuthToken");
final String twilioPhoneNumber = ApiKeysUtils.getApiKey("twilioPhoneNumber");
// Twilio.init(accountSid, authToken);
// Message message = Message.creator(
// new PhoneNumber(phoneNumber), // To number
// new PhoneNumber(twilioPhoneNumber), // From number
// smsMessage // SMS body
// ).create();
// LOG.warning(message.toString());
TwilioRestClient client = new TwilioRestClient(accountSid, authToken);
Account account = client.getAccount();
MessageFactory messageFactory = account.getMessageFactory();
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("To", phoneNumber));
params.add(new BasicNameValuePair("From", twilioPhoneNumber));
params.add(new BasicNameValuePair("Body", smsMessage));
Message sms = messageFactory.create(params);
LOG.warning(sms.toString());
return sms;
}
开发者ID:Cryptonomica,项目名称:cryptonomica,代码行数:33,代码来源:TwilioUtils.java
示例12: main
import com.twilio.sdk.resource.instance.Account; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Build a filter for the AccountList
Map<String, String> params = new HashMap<String, String>();
params.put("Status", "active");
AccountList accounts = client.getAccounts(params);
// Loop over accounts and print out a property for each one.
for (Account account : accounts) {
System.out.println(account.getFriendlyName());
}
}
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:17,代码来源:list-get-example-2.6.x.java
示例13: main
import com.twilio.sdk.resource.instance.Account; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
// Build a filter for the AccountList
Map<String, String> params = new HashMap<String, String>();
params.put("FriendlyName", "MySubaccount");
AccountList accounts = client.getAccounts(params);
// Loop over accounts and print out a property for each one.
for (Account account : accounts) {
System.out.println(account.getStatus());
}
}
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:17,代码来源:listing-subaccounts-example-2.6.x.java
示例14: main
import com.twilio.sdk.resource.instance.Account; //导入依赖的package包/类
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
AccountList accounts = client.getAccounts();
// Loop over accounts and print out a property for each one.
for (Account account : accounts) {
System.out.println(account.getDateCreated());
}
}
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:14,代码来源:list-get-example-1.6.x.java
注:本文中的com.twilio.sdk.resource.instance.Account类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论