Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Twilio进行调用时,是否有方法传递自定义参数?_Twilio_Twilio Php - Fatal编程技术网

使用Twilio进行调用时,是否有方法传递自定义参数?

使用Twilio进行调用时,是否有方法传递自定义参数?,twilio,twilio-php,Twilio,Twilio Php,我使用的是TwilioPHP库,但问题实际上是语言不可知。我试着做如下的事情: $client = new Services_Twilio('MyAccountSID', 'My auth token'); $client->account->calls->create($from_number, $to_number, $url_or_AppSID, array( 'TwilioParam1' => 'value1', 'TwilioParam2' =&

我使用的是TwilioPHP库,但问题实际上是语言不可知。我试着做如下的事情:

$client = new Services_Twilio('MyAccountSID', 'My auth token');
$client->account->calls->create($from_number, $to_number, $url_or_AppSID, array(
    'TwilioParam1' => 'value1',
    'TwilioParam2' => 'value2',
    'MyCustomParameter1' => 'CustomValue1',
    'MyCustomParamete2' => 'CustomValue2'
));
然后,当Twilio请求我的$url\u或\u AppSID(我的TwiML应用程序)时,我希望收到这些参数,但没有发生。 我知道,一种可能的方法是构建一个URL,在查询字符串中添加这些参数,然后传入我的自定义URL $url_或_AppSID参数,但这迫使我设置GET方法,我希望通过POST请求传递自定义参数,而不是GET。 另外,我可能必须使用AppSID,它已经通过POST注册了一个请求URL


是否有使用POST方法传递自定义参数的方法?

POST
中可能没有发送自定义参数的方法。发送的唯一方法是在
GET
中构造
URL

最后一个参数数组只能包含特定的
,即senddights、IfMachine、Timeout


最后,我收到了Twilio支持部门的回复:

不幸的是,您不能添加如下自定义参数。您是正确的,唯一能够做到这一点的方法是将参数添加到querystring中,我们只需将这些参数传递给您的应用程序

然后我向他们发送了一个功能请求:

我认为这应该考虑到未来的发布

他们回答我:

如果此功能请求不存在。我会加上它


我们将继续关注未来的版本

Twilio将一个唯一的调用SID与每个调用相关联,由于该参数在创建调用和Twilio向处理程序发出请求时都可用,因此我可以使用自己的数据库传递参数

使用数据库似乎是一项相当大的开销,但如果我还想存储通话的“结果”(例如,客户是否拿起了电话?我们是否使用了自动机器?),我已经实现了所有必要的功能

因此,我调用的Java代码如下所示:

Map<String, String> params = new HashMap<String, String>();
params.put("From", myTwilioPhoneNumber);
params.put("To", customerPhone);
params.put("Url", myHandlerUrl));
Call call = client.getAccount().getCallFactory().create(params);
// THE LINE BELOW IS THE KEY TO PARAMETER PASSING
db.store(call.getSid(), myCustomParametersJSON);

谢谢@mansoor。我已经查看了所有文档,他们没有提到任何有关自定义参数的内容,但我一直希望有人知道一些方法来做到这一点,但最终Twilio支持部门证实了我们的猜测:(它仍然悬而未决:DStill pending直到现在仍然悬而未决:(
Sting callSid = request.getParameter("CallSid");
// Optionally sleep 20 ms to make sure that data written by
// db.store(call.getSid(), myCustomParametersJSON);
// can now be read.
CustomData customData = parseJSON(db.fetchKey(callSid));
TwiMLResponse twimlResponse = new TwiMLResponse();
Say sayMessage = new Say(makeCustomMessage(customData));
twimlResponse.append(sayMessage);
...