当前位置:主页 > 云服务器 > 正文

美国服务器_东莞服务器租用_限量秒杀

时间:2021-07-22 20:15 来源:埃里克云 编辑:埃里克云

核心提示

Hey followers! Who is ready for another edition of #APIFriday?! I’m going to keep this one short and sweet. Today, we’re going to create a button you can add to your application to send a text message. Using Twilio, you can easily ad...

Hey followers! Who is ready for another edition of #APIFriday?! I’m going to keep this one short and sweet. Today, we’re going to create a button you can add to your application to send a text message. Using Twilio, you can easily add the ability to send a SMS, MMS, voice calls, and 2 factor authentication.

To get started, you will need to sign up for a Twilio account and get a phone number. The trial version of the account is enough for this demo. Take a minute to read over the Twilio REST API documentation for sending and receiving messages as that is what we will be basing the AJAX call off of. I used the Curl code as a basis for my AJAX call construction. We will use a destination so the Authentication is handled for us and the –data flags will be part of the JSON data body of the AJAX call. We won’t be sending a picture, so you can ignore the media. We’ll be accessing the Messages endpoint.

Once you get your free API key, make sure to get a phone number. Click on the Programmable SMS icon (text message bubbles) and selected Getting Started. You will be able to generate a phone to use as your Twilio number for sending and receiving messages.

Make a note of your Account SID and Auth Token. This will be used in your authentication process. Twilio uses Basic Authentication (yay!) where the Account SID is your username and the Auth Toke is the password. You will need these for you SAP Cloud Platform destination.

Let’s move over to your SAP Cloud Platform instance! Go to your Destinations and select New Destination.

Go ahead and Save your destination. When the option appears, select Check Connection. You should get a green check saying the connection is successful. Awesome! Now we are ready to add it to our app! Open your Web IDE, or if you already have it open, refresh your Web IDE. Don’t forget that whenever you create a new destination or modify a old destination, you MUST refresh your Web IDE so the changes are available. If you don’t refresh, you will be grabbing the outdated destination information.

We’ll be creating a button so you can either add it to an existing app or create a new app. Choice is yours! I started with a fresh SAPUI5 App template project because I didn’t link the layouts of my existing apps to add a button too. However you do it, just make sure you have a view and a controller ready to go. First things first, adding the route to our manifest.json file. Since we configured the URL and Auth as a CP destination, we need to tell Web IDE that we are using the Twilio destination and where to find it. Add the Twilio destination to your routes array and save your changes. If you are a little rusty with using an API in your app via destinations, check out this tutorial as a refresher.

In your View file, let’s go ahead and add the button control. In your tags, add a . Don’t forget to define your button text and a press function which we’ll create in the controller next.

As always, SAVE your changes before switching over to the controller. If you want to run your app to make sure the button is showing up, go ahead! Then meet me in your controller.

In the corresponding Controller (for the view we just updated), create your new press function. In your AJAX call, we will specify the type as POST, since we need to include data, and the data array will contain the TO phone number (in this case, I used my personal number), the FROM phone number (your Twilio number), and the body or what you want the SMS to say. You will need your account SID to construct the URL. We are using the Messages.json endpoint to send a SMS message.

I defined myPhoneNumber and myTwilioNumber as global variables. Don’t forget to include the "+1" before your number. The country code IS necessary. Save your controller and run your application. You will see a new "Text me!" button in your UI. NOTE: If implemented correctly, this WILL actually SEND a SMS message to the specified TO number. Messaging rates may apply for the receipt so be thoughtful in your messaging choice. Open your Developer Console (by using F12 for PC or CMD+OPT+i for Mac in Chrome). When you click the button, you should see the response from Twilio. If it is successful, you will receive a SMS message on the TO phone number.

Add that’s how simple it is to send a text message from a SAPUI5 app! You can add an input field for the TO phone number and message or you could automate SMS alerts and use data from the triggering event for the message. You’ve got the basics and now the world is your oyster!

Thanks for joining me again this week for #APIFriday!

Next Friday, we’ll take a look at using an external library SDK called JustGages to spiffy up your application, I am using it for my current kegerator project, which we’ll be wrapping up phase 1 at the end of next week, so I can take you through my adventure in making a flashy app. Also on tap is a friend’s playlist app for Spotify requested by my teammate Lucia. As I am not a Spotify user (GASP!), I wanted to take the time to get to know the tool before I start building with it. Sorry for the delay Lucia, but I promise it’s coming!

  • <strong>云存储_佛山顺德网站建设_超低折扣</strong> 云存储_佛山顺德网站建设_超低折扣

    您是否有过这样的问题:是否可以将事务FBL5N(客户行项目显示)移植到Webdynpro?不?你真幸运!重建FBL5N不是我最喜欢做的5件事,所以当我得到这个问题时,我很不愿意开始。幸运的...

  • <strong>云主机_获取服务器地址_促销</strong> 云主机_获取服务器地址_促销

    到目前为止,我们已经创建了两个应用程序。一个用于维护员工特定的奖金计划,另一个用于授予员工奖金。到目前为止,奖金仅取决于已完成销售订单的净额。 任务:在自定义业务...

  • <strong>天翼云_免费虚拟主机管理系统_免费6个月</strong> 天翼云_免费虚拟主机管理系统_免费6个月

    任务:在标准业务对象上创建自定义字段。 示例:要计算与产品相关的奖金,标准业务对象"产品"将获得奖金百分比的自定义字段 要能够打开并调整"管理产品主数据"应用程序的UI您的...

  • <strong>阿里云_美橙互联云主机_怎么样</strong> 阿里云_美橙互联云主机_怎么样

    任务:在标准业务对象上创建自定义字段。 示例:要计算与产品相关的奖金,标准业务对象"产品"将获得奖金有效期的自定义字段。 要适应"管理产品主数据"应用程序的UI,您的用户需...

  • <strong>香港服务器_数据库上机实验_速度快</strong> 香港服务器_数据库上机实验_速度快

    到目前为止,我们已经创建了两个应用程序。一个是维护员工特定的奖金计划,另一个是为员工发放奖金。到目前为止,奖金权利仅取决于已完成销售订单的净额,但在奖金计划中,...

  • <strong>域名备案_数据库文本类型_新注册优惠</strong> 域名备案_数据库文本类型_新注册优惠

    各位开发人员好, 这里我要写一个关于sapui5的有趣话题。根据状态更改sap.m.表的整行颜色。通常我们在状态字段中保留一个文本,并根据状态更改文本的颜色。但是,现在客户问这个...

  • <strong>专属服务器_数据库显示正在还原_企业级</strong> 专属服务器_数据库显示正在还原_企业级

    多年来,SAP客户一直有机会要求对SAP功能进行更改,并就所提供的软件解决方案提出改进建议。 以前我们有开发要求,如今,这已被客户的影响力所取代项目该项目的主要目的是收集...

  • <strong>CDN_合肥建设网站_新用户</strong> CDN_合肥建设网站_新用户

    我写这个博客是为了展示一个场景,向 添加一个自定义标题sap.ui.unified.Shell控件。 统一的Shell控件不直接提供标题财产。还有外壳被分成几个区域,比如左边的菜单按钮,搜索栏位于...

  • <strong>香港服务器_中国近代报刊数据库_安全稳</strong> 香港服务器_中国近代报刊数据库_安全稳

    大家好, 我正在使用企业门户7.5版。 在使用自定义splash映像时,我在使用显示规则中配置的AJAX框架页面登录门户时遇到了splash映像的外观问题。 在我的情况下,Splash图像垂直向下显...