twilio 평가판 계정으로 전화를 걸려고합니다. 이건 link입니다.Twilio를 사용하여 브라우저에서 전화 걸기 - 전화가 자동으로 종료됩니다.
<?php
header('Content-type: text/xml');
// put a phone number you've verified with Twilio to use as a caller ID number
$callerId = "+xxxxxxxxxx";
// put your default Twilio Client name here, for when a phone number isn't given
$number = "jenny";
// get the phone number from the page request parameters, if given
if (isset($_REQUEST['PhoneNumber'])) {
$number = htmlspecialchars($_REQUEST['PhoneNumber']);
}
// wrap the phone number or client name in the appropriate TwiML verb
// by checking if the number given has only digits and format symbols
if (preg_match("/^[\d\+\-\(\) ]+$/", $number)) {
$numberOrClient = "<Number>" . $number . "</Number>";
} else {
$numberOrClient = "<Client>" . $number . "</Client>";
}
?>
<Response>
<Dial callerId="<?php echo $callerId ?>">
<?php echo $numberOrClient ?>
</Dial>
</Response>
및 안녕하세요 - 클라이언트 monkey.php 페이지 코드 :
<?php
include "vendor/autoload.php";
use Twilio\Jwt\ClientToken;
// put your Twilio API credentials here
$accountSid = 'your_sid_here';
$authToken = 'your_auth_token';
// put your TwiML Application Sid here
$appSid = 'APXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$capability = new ClientToken($accountSid, $authToken);
$capability->allowClientOutgoing($appSid);
$capability->allowClientIncoming('jenny');
$token = $capability->generateToken();
?>
<!DOCTYPE html>
<html>
<head>
<title>Hello Client Monkey 4</title>
<script type="text/javascript"
src="//media.twiliocdn.com/sdk/js/client/v1.3/twilio.min.js"></script>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<link href="//static0.twilio.com/resources/quickstart/client.css"
type="text/css" rel="stylesheet" />
<script type="text/javascript">
Twilio.Device.setup("<?php echo $token; ?>");
Twilio.Device.ready(function (device) {
$("#log").text("Ready");
});
Twilio.Device.error(function (error) {
$("#log").text("Error: " + error.message);
});
Twilio.Device.connect(function (conn) {
$("#log").text("Successfully established call");
});
Twilio.Device.disconnect(function (conn) {
$("#log").text("Call ended");
});
Twilio.Device.incoming(function (conn) {
$("#log").text("Incoming connection from " + conn.parameters.From);
// accept the incoming connection and start two-way audio
conn.accept();
});
function call() {
// get the phone number to connect the call to
params = {"PhoneNumber": $("#number").val()};
Twilio.Device.connect(params);
}
function hangup() {
Twilio.Device.disconnectAll();
}
</script>
</head>
<body>
<button class="call" onclick="call();">
Call
</button>
<button class="hangup" onclick="hangup();">
Hangup
</button>
<input type="text" id="number" name="number"
placeholder="Enter a phone number to call"/>
<div id="log">Loading pigeons...</div>
</body>
</html>
이 링크를 기반으로, 나는 다음 코드를 사용하여 한 페이지라는
안녕하세요 - 클라이언트 twiml.php을 만들었습니다
Twilio 콘솔에서 TwiML apps page으로 http://mywebsite.com/hello-client-monkey.php을 음성 -> 요청 URL으로 추가했습니다. 내가 페이지를 안녕하세요 - 클라이언트 monkey.php을 실행할 때 이제
, 통화가 자동으로 종료지고와 twilio console logs에 나는대로 오류 로그 받고 있어요 :
이WARNING
12200 Schema validation warning
DESCRIPTION
Cannot find the declaration of element 'html'.
누군가가 나를 도울 수를 이 문제를 해결 하시겠습니까? 미리 감사드립니다. 워드 프로세서
여기에 Twilio 전도사가 있습니다. 'hello-client-monkey.php' URL이 아닌'hello-client-twiml.php' URL로 TwiML 애플리케이션을 구성해야하는 것 같습니다. –
@Devin ... TwiML을'hello-client-twiml.php' URL로 설정했습니다. 그러나 그것은 작동하지 않고 twilio 콘솔 로그를 얻는 것과 같습니다 :'이 이벤트에 대한 HTTP 요청이 기록되지 않았습니다. ' – Jenz
@ DevinRader .. 또한 내 twilio 번호는 미국 번호이고 인도의 모바일에 전화하려고합니다. 재판 계좌에 대한 제한 사항이 있습니까? – Jenz