当我试图使用[TwilioVoice Call]方法从我的应用程序中传递param时,我无法在twiML应用程序上获得这些param。但是,当我试图从POSTMAN和FormData传递相同的数据时,它工作得很好,而且还能够成功地创建调用。
请帮助我如何使用从我的iOS应用程序传递到twiML的param?
PHP中的TwiML应用程序:
<?php
/*
* Makes a call to the specified client using the Twilio REST API.
*/
include('./vendor/autoload.php');
include('./config.php');
$to = isset($_GET["to"]) ? $_GET["to"] : "";
if (!isset($to) || empty($to)) {
$to = isset($POST["to"]) ? $_POST["to"] : "";
}
$from = isset($_GET["from"]) ? $_GET["from"] : "";
if (!isset($from) || empty($from)) {
$from = isset($POST["from"]) ? $_POST["from"] : "";
}
use Twilio\Twiml;
$response = new Twiml();
$dial = $response->dial(['callerId' => $from]);
$dial->client($to);
echo $response;iOS目标-C :
self.call = [TwilioVoice call:[self fetchAccessToken]
params:@{@"to": @"1",@"from":@"2"}
uuid:uuid
delegate:self];Twilio错误日志当我试图从iOS传递param时
警告- 13224拨号: Twilio不支持拨打此号码,否则号码无效

参考TwiML应用程序代码
发布于 2018-02-26 05:22:36
两位开发人员在这里传道。
12100误差来自Twilio无法解析从服务器返回的TwiML。在这种情况下,这是因为您的PHP没有返回TwiML,而是尝试使用REST进行调用。
它应该返回一个带有嵌套的。您也可以使用助手库来构建这个库。尝试将代码更改为:
<?php
include('./vendor/autoload.php');
include('./config.php');
$to = isset($_REQUEST["To"]) ? $_REQUEST["To"] : "";
$to = str_replace("client:", "", $to);
$from = isset($_REQUEST["From"]) ? $_REQUEST["From"] : "";
use Twilio\Twiml;
$response = new Twiml();
$dial = $response->dial(['callerId' => $from]);
$dial->client($to);
echo $response;如果这有帮助的话请告诉我。
发布于 2019-03-30 10:33:06
步骤1。在名称中,必须传递用户的名称(任何您想要的东西)。
步骤2.您需要使用3个参数生成令牌
步骤3.您需要创建VoiceGrant的对象
步骤4.您需要传递Id
步骤5.您需要设置从twilio生成的PUSH通知Id
$name = $this->input->post('name');
//$PUSH_CREDENTIAL_SID = 'CRaf1a66dd4a7656876e16c7820ef5c01e';
$outgoingApplicationSid = 'APf9b1b789ba690b8789d95a42511f2018';
// choose a random username for the connecting user
$identity = $name;
// Create access token, which we will serialize and send to the client
$token = new AccessToken(
$this->twilioAccountSid,
$this->twilioApiKey,
$this->twilioApiSecret,
3600,
$identity
);
// $chatGrant = new ChatGrant( $pushCredentialSid= "CRaf1a66dd4a7656876e16c7820ef5c01e");
//
// print_r($chatGrant);die;
// Create Chat grant
// $voiceGrant = new VoiceGrant($serviceSid = 'IS840a7e5f64634ab6bf179c3f8b0adfc4',$pushCredentialSid = 'CRaf1a66dd4a7656876e16c7820ef5c01e');
$voiceGrant = new VoiceGrant();
$voiceGrant->setOutgoingApplicationSid($outgoingApplicationSid);
// Optional: add to allow incoming calls
$voiceGrant->setIncomingAllow(true);
$voiceGrant->setPushCredentialSid('CRaf1a66dd4a7656876e16c7820ef5c01e');
// Add grant to token
$token->addGrant($voiceGrant);
// render token to string
$voice_token = $token->toJWT();
if($voice_token){
$data['token'] = $voice_token;
$this->response = array('status'=>1,'data'=>$data);
}else{
$this->response = array('status'=>0,'message'=>'Not found');
}https://stackoverflow.com/questions/48942625
复制相似问题