2013-05-03 21 views
0

我想將服務集成爲。除此之外,我們的產品登錄將會呼叫用戶給他們一個代碼。用於呼出消息的雲服務

我可以生成代碼爲MP3沒有問題,但我不知道可以發出呼叫,然後播放MP3給用戶的服務。

有關這類應用程序的任何想法或反饋需要?

回答

0

強烈推薦Twilio雲通信,它可以用於通過短信或通過電話發送代碼。

使用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來實現這一點。希望這可以幫助!

0

我想知道是否像Twilio雲通信的東西會工作。

相關問題