最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

twilio php 发送短信,Twilio发送短信

IT圈 admin 47浏览 0评论

twilio php 发送短信,Twilio发送短信

简介

Twilio 为将来的商业沟通提供强大支持,并使开发人员能够将语音、VoIP 和消息传送嵌入到应用程序中。 它们对基于云的全球环境中所需的所有基础结构进行虚拟化,并通过 Twilio 通信 API 平台将其公开。 可轻松构建和扩展应用程序。 享受现用现付定价所带来的灵活性,并从云可靠性中受益。

利用 Twilio 语音,应用程序可以发起和接收电话呼叫。 Twilio SMS 使应用程序能够发送和接收文本消息。 利用 Twilio 客户端,可以从任何手机、平板电脑或浏览器发起 VoIP 呼叫并支持 WebRTC。

账号注册

关于账号注册可以参考这篇文章 :

准备

使用前需要登陆官网获取三个参数accountSid

authToken

fromPhoneNumber

使用创建maven工程,添加依赖。

com.twilio.sdk

twilio

7.17.0

编写代码@RunWith(SpringRunner.class)

@SpringBootTest

public class DemoApplicationTests {

private static final String accountSid = "ACxxxx"; // Your Account SID from www.twilio.com/user/account

private static final String authToken = "xxxx"; // Your Auth Token from www.twilio.com/user/account

@Test

public void contextLoads() {

Twilio.init(accountSid, authToken);

Message message = Message.creator(

new PhoneNumber("+xxx"), // To number ,Phone number with area code

new PhoneNumber("+xxx"), // From number

" A book is the same today as it always was and it will never change." // SMS body

).create();

if (! StringUtils.isEmpty(message.getSid())){

System.out.println(message.getSid());

}

}

@Test

public void sendCall() throws URISyntaxException {

Twilio.init(accountSid, authToken);

Call call = Call.creator(

new PhoneNumber("+xxxx"), // To number

new PhoneNumber("+xxxx"), // From number

// Read TwiML at this URL when a call connects (hold music)

new URI("=com.twilio.music.ambient")

).create();

if (! StringUtils.isEmpty(call.getSid())){

System.out.println(call.getSid());

}

}

}

结果

手机可以正常收到短信,使用的时候发送频率控制在1s一条

参考

twilio php 发送短信,Twilio发送短信

简介

Twilio 为将来的商业沟通提供强大支持,并使开发人员能够将语音、VoIP 和消息传送嵌入到应用程序中。 它们对基于云的全球环境中所需的所有基础结构进行虚拟化,并通过 Twilio 通信 API 平台将其公开。 可轻松构建和扩展应用程序。 享受现用现付定价所带来的灵活性,并从云可靠性中受益。

利用 Twilio 语音,应用程序可以发起和接收电话呼叫。 Twilio SMS 使应用程序能够发送和接收文本消息。 利用 Twilio 客户端,可以从任何手机、平板电脑或浏览器发起 VoIP 呼叫并支持 WebRTC。

账号注册

关于账号注册可以参考这篇文章 :

准备

使用前需要登陆官网获取三个参数accountSid

authToken

fromPhoneNumber

使用创建maven工程,添加依赖。

com.twilio.sdk

twilio

7.17.0

编写代码@RunWith(SpringRunner.class)

@SpringBootTest

public class DemoApplicationTests {

private static final String accountSid = "ACxxxx"; // Your Account SID from www.twilio.com/user/account

private static final String authToken = "xxxx"; // Your Auth Token from www.twilio.com/user/account

@Test

public void contextLoads() {

Twilio.init(accountSid, authToken);

Message message = Message.creator(

new PhoneNumber("+xxx"), // To number ,Phone number with area code

new PhoneNumber("+xxx"), // From number

" A book is the same today as it always was and it will never change." // SMS body

).create();

if (! StringUtils.isEmpty(message.getSid())){

System.out.println(message.getSid());

}

}

@Test

public void sendCall() throws URISyntaxException {

Twilio.init(accountSid, authToken);

Call call = Call.creator(

new PhoneNumber("+xxxx"), // To number

new PhoneNumber("+xxxx"), // From number

// Read TwiML at this URL when a call connects (hold music)

new URI("=com.twilio.music.ambient")

).create();

if (! StringUtils.isEmpty(call.getSid())){

System.out.println(call.getSid());

}

}

}

结果

手机可以正常收到短信,使用的时候发送频率控制在1s一条

参考

发布评论

评论列表 (0)

  1. 暂无评论