用于出站呼叫消息的云服务

时间:2013-05-03 02:23:21

标签: api messaging voip voice

我想将服务整合为。除了我们的产品登录,它将呼叫用户给他们一个代码。

我可以毫无问题地生成代码为mp3但我不知道可以发出呼叫然后向用户播放mp3的服务。

对此类应用的任何想法或反馈都需要?

2 个答案:

答案 0 :(得分:0)

我想知道像Twilio Cloud Communications这样的东西是否会起作用。

答案 1 :(得分:0)

强烈推荐Twilio Cloud Communication,它可用于通过短信或电话发送代码。

以PHP为例,以下是它的外观 -

短信

<?php
// Get the Twilio PHP Library from http://twilio.com/docs/libraries
require "Services/Twilio.php";

//Random Code
$code = rand(pow(10, 6-1), pow(10, 6)-1);

// Set your Twilio Account settings
$AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$AuthToken = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";

//Initial Twilio instance
$client = new Services_Twilio($AccountSid, $AuthToken);

//Recipient number - must be +15555555555 format
$recipient = '+18882224444';
$caller_id = '+18008885555'; //Twilio phone number

//Send the message
$sms = $client->account->sms_messages->create(
    $caller_id,
    $recipient,
    "Your activation code is: $code"
);

致电

<?php
// Get the Twilio PHP Library from http://twilio.com/docs/libraries
require "Services/Twilio.php";

// Set your Twilio Account settings
$AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$AuthToken = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";

//Initial Twilio instance
$client = new Services_Twilio($AccountSid, $AuthToken);
$call = $client->account->calls->create(
    '9991231234', // From a valid Twilio number
    '8881231234', // Call this number

    //When the call is connected, code at this URL will be executed
    '/say-code.php'
);

<强>说-code.php

<?php
// Get the Twilio PHP Library from http://twilio.com/docs/libraries
require "Services/Twilio.php";
// Random Code
$code = rand(pow(10, 6-1), pow(10, 6)-1);

// Generate TwiML - XML for Twilio
// This will execute when the caller is connected and use Text-To-Speech to
// play their activation code.
// You may also use an MP3 like so:
// $response->play('http://example.com/code.mp3');
$response = new Services_Twilio_Twiml();
$response->say("Your activation code is $code");
print $response;

还有很多其他帮助程序库可以用Twilio实现这一目标。希望这有帮助!