{"id":1779,"date":"2020-07-17T06:43:42","date_gmt":"2020-07-16T21:43:42","guid":{"rendered":"https:\/\/esoro.jp\/?p=1779"},"modified":"2020-07-17T06:45:23","modified_gmt":"2020-07-16T21:45:23","slug":"%e3%80%8ctwilio%e3%80%8d%e3%81%a7%e9%9b%bb%e8%a9%b1%e3%82%92%e3%81%8b%e3%81%91%e3%81%a6%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/esoro.jp\/?p=1779","title":{"rendered":"\u300cTwilio\u300d\u3067\u96fb\u8a71\u3092\u304b\u3051\u3066\u307f\u305f"},"content":{"rendered":"<p>\u81ea\u52d5\u3067\u96fb\u8a71\u3092\u304b\u3051\u305f\u3044\u306a\u3002<br \/>\n\u3068\u3044\u3046\u8a71\u3067\u3001Twilio\u3092\u30c8\u30e9\u30a4\u30a2\u30eb\u3057\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u8981\u4ef6\u3068\u3057\u3066\u306f\u67b6\u96fb\u3057\u3066\u76f8\u624b\u306b\u65e5\u672c\u8a9e\u3067\u8981\u4ef6\u3092\u9023\u7d61\u3001\u901a\u8a71\u3067\u304d\u305f\u304b\u3092\u5224\u5b9a\u3057\u3066\u30fb\u30fb\u30fb\u3068\u3044\u3046\u3068\u3053\u308d\u3067\u3059\u3002<\/p>\n<p>Twilio\u306b\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u3001\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u3067\u96fb\u8a71\u756a\u53f7\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<br \/>\nDOC\u3092\u53c2\u7167\u3057\u306a\u304c\u3089\u3001\u3068\u308a\u3042\u3048\u305a\u8a66\u3059\u3060\u3051\u306a\u306e\u3067\u3001Java\u3067\u9069\u5f53\u306b\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\n\u57fa\u672c\u7684\u306a\u3068\u3053\u308d\u306f\u3001\u4e0b\u8a18\u3092\u53c2\u8003\u306b\u3055\u305b\u3066\u9802\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>[blogcard url=&#8221;https:\/\/qiita.com\/mosin_nozomi\/items\/d30811022f1a19e620e0&#8243;]<\/p>\n<p>SMS\u306e\u767a\u4fe1\u3084\u96fb\u8a71\u3092\u304b\u3051\u308b\u3068\u3053\u308d\u307e\u3067\u306f\u7279\u306b\u554f\u984c\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u304c\u3001\u4e0a\u8a18\u30b5\u30a4\u30c8\u306e\u5185\u5bb9\u3068\u306f\u73fe\u6642\u70b9\u3067\u5909\u308f\u3063\u3066\u3044\u308b\u306e\u304b\u3001\u306a\u304b\u306a\u304b\u65e5\u672c\u8a9e\u3092\u558b\u3063\u3066\u304f\u308c\u307e\u305b\u3093\u3002<br \/>\n\u3042\u3068\u3001\u30c8\u30e9\u30a4\u30a2\u30eb\u7740\u4fe1\u306e\u300c\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u306d\u300d\u6587\u53e5\u306e\u5f8c\u306b\u4f55\u304b\u62bc\u3055\u306a\u304f\u3066\u306f\u3044\u3051\u306a\u3044\u3068\u3044\u3046\u306e\u3082\u66ab\u304f\u3057\u3066\u6c17\u304c\u4ed8\u304d\u307e\u3057\u305f\u3002\u3002<\/p>\n<p>\u3069\u3046\u3057\u305f\u3089\u65e5\u672c\u8a9e\u3092\u558b\u3063\u3066\u304f\u308c\u308b\u306e\u304b\u3068\u3001\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u898b\u306a\u304c\u3089alice\u3068\u304b\u3092\u8a66\u3057\u3066\u307f\u305f\u308a\u3057\u307e\u3057\u305f\u304c\u3001\u4f55\u304b\u30b4\u30cb\u30e7\u30b4\u30cb\u30e7\u8a00\u3063\u3066\u308b\u3051\u3069\u4f55\u3092\u8a00\u3063\u3066\u3044\u308b\u306e\u304b\u4e0d\u660e\u3002\u3002<br \/>\n\u7d50\u679c\u7684\u306b\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u5de6\u30e1\u30cb\u30e5\u30fc\u306e\u30b5\u30fc\u30d3\u30b9\u2192Programmable Voice\u2192TwiML\u2192\u30c6\u30ad\u30b9\u30c8\u97f3\u58f0\u5909\u63db\u306eText-to-Speech\u3068\u3044\u3046\u6240\u306b\u65e5\u672c\u8a9e\u306fMizuki\u3060\u3068\u66f8\u3044\u3066\u3042\u3063\u305f\u306e\u3067\u3001\u3084\u3063\u3066\u307f\u308b\u3068\u3084\u3063\u3068\u558b\u3063\u3066\u304f\u308c\u307e\u3057\u305f\u3002\u3042\u308a\u304c\u3068\u3046Mizuki\u3055\u3093\u3002<\/p>\n<p>\u3042\u3068\u3001TwiML\u3092\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u4e0a\u306eURL\u304b\u3089POST\u3067\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u304f\u3001\u3068\u3044\u3046\u8b0e\u306e\u5236\u7d04\u3082\u304b\u306a\u308a\u5384\u4ecb\u3060\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u3053\u3061\u3089\u3082\u7d50\u679c\u7684\u306b\u4e0b\u8a18\u306e\u3088\u3046\u306b\u3059\u308b\u3068\u5fc5\u9808\u3067\u306f\u7121\u304b\u3063\u305f\u3088\u3046\u3067\u3059\u3002<\/p>\n<pre class=\"lang:java decode:true \" title=\"Example.java\" >import com.twilio.Twilio;\r\nimport com.twilio.rest.api.v2010.account.Call;\r\nimport com.twilio.type.PhoneNumber;\r\nimport com.twilio.type.Twiml;\r\n\r\npublic class Example {\r\n    public static final String ACCOUNT_SID = \"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\";\r\n    public static final String AUTH_TOKEN = \"your_auth_token\";\r\n\r\n    public static void main(String[] args) throws Exception {\r\n        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);\r\n        String callText = \"\u304a\u75b2\u308c\u69d8\u3067\u3059\u3002\u4e86\u89e3\u9802\u3051\u307e\u3057\u305f\u3089\u3001\u4e86\u89e3\u306e\u65e8\u3092\u5fdc\u7b54\u9802\u3051\u307e\u3059\u3067\u3057\u3087\u3046\u304b\uff1f\";\r\n        String TwiMLstr = \"&lt;?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?&gt;&lt;Response&gt;&lt;Say language=\\\"ja-JP\\\" voice=\\\"Mizuki\\\"&gt;\"\r\n                + callText + \"&lt;\/Say&gt;&lt;Pause length=\\\"10\\\"\/&gt;&lt;Say language=\\\"ja-JP\\\" voice=\\\"Mizuki\\\"&gt;\u305d\u308c\u3067\u306f\u5b9c\u3057\u304f\u304a\u9858\u3044\u3057\u307e\u3059\u3002&lt;\/Say&gt;&lt;\/Response&gt;\";\r\n        Twiml TwiML = new Twiml(TwiMLstr);\r\n\r\n        Call call = Call.creator(new PhoneNumber(\"+81\u767b\u9332\u3057\u305f\u96fb\u8a71\u756a\u53f7\"), new PhoneNumber(\"+\u53d6\u5f97\u3057\u305f\u96fb\u8a71\u756a\u53f7\"), TwiML).create();\r\n\r\n        String id = call.getSid();\r\n        for(int i = 0 ; i &lt; 10 ; i++){\r\n            Thread.sleep(1000*5);\r\n            call = Call.fetcher(id).fetch();\r\n            if(call.getStatus() == Call.Status.RINGING ||\r\n                call.getStatus() == Call.Status.IN_PROGRESS ||\r\n                call.getStatus() == Call.Status.QUEUED){\r\n                continue;\r\n            }\r\n            else if(call.getStatus() == Call.Status.COMPLETED){\r\n                \/\/\u7740\u4fe1OK\r\n                System.out.println(\"Call Completed \" + call.getAnsweredBy());\r\n            }\r\n            else{\r\n                break;\r\n            }\r\n        }\r\n        System.out.println(call.toString());\r\n    }\r\n}\r\n<\/pre>\n<p>\u3068\u308a\u3042\u3048\u305a\u8981\u4ef6\u306f\u6e80\u305f\u305b\u305d\u3046\u3067\u3059\u3002<br \/>\n\u901a\u8a71\u5224\u5b9a\u306f\u3082\u3063\u3068\u30b1\u30fc\u30b9\u304c\u5fc5\u8981\u3067\u3059\u3057\u3001\u5224\u5b9a\u5f85\u3061\u3092\u3082\u3063\u3068\u307e\u3057\u306a\u5f62\u306b\u3057\u305f\u3044\u3068\u3053\u308d\u3067\u3059\u304c\u3001\u30c8\u30e9\u30a4\u30a2\u30eb\u306a\u306e\u3067\u3053\u3053\u307e\u3067\u3002<\/p>\n<p>\u30e9\u30f3\u30cb\u30f3\u30b0\u30b3\u30b9\u30c8\u304cOK\u306b\u306a\u3063\u3066\u5b9f\u969b\u306b\u5c0e\u5165\u3059\u308b\u3068\u6c7a\u307e\u3063\u305f\u3089\u3001\u3082\u3046\u3061\u3087\u3063\u3068\u8abf\u3079\u306a\u3044\u3068\u3067\u3059\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea\u52d5\u3067\u96fb\u8a71\u3092\u304b\u3051\u305f\u3044\u306a\u3002 \u3068\u3044\u3046\u8a71\u3067\u3001Twilio\u3092\u30c8\u30e9\u30a4\u30a2\u30eb\u3057\u3066\u307f\u307e\u3057\u305f\u3002 \u8981 &hellip; <a href=\"https:\/\/esoro.jp\/?p=1779\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/posts\/1779"}],"collection":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1779"}],"version-history":[{"count":0,"href":"https:\/\/esoro.jp\/index.php?rest_route=\/wp\/v2\/posts\/1779\/revisions"}],"wp:attachment":[{"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/esoro.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}