【发布时间】:2017-04-19 03:27:03
【问题描述】:
我正在使用 Twilio 的 PHP SDK 发送短信。下面是代码:
<?php
// Required if your environment does not handle autoloading
require './autoload.php';
// Use the REST API Client to make requests to the Twilio REST API
use Twilio\Rest\Client;
// Your Account SID and Auth Token from twilio.com/console
$sid = 'XXXXXXXXXXXXXXXXXXXXXXXX';
$token = 'XXXXXXXXXXXXXXXXXXXX';
$client = new Client($sid, $token);
// Use the client to do fun stuff like send text messages!
$client->messages->create(
// the number you'd like to send the message to
'+XXXXXXXXXX',
array(
// A Twilio phone number you purchased at twilio.com/console
'from' => '+XXXXXXXX',
// the body of the text message you'd like to send
'body' => 'Hey Jenny! Good luck on the bar exam!'
)
);
**Response:
[Twilio.Api.V2010.MessageInstance accountSid=XXXXXXXXXXXXXXXX sid=XXXXXXXXXXXXXXX]**
如何获得 JSON 格式的响应? 任何帮助表示赞赏。
【问题讨论】:
-
任何人请..
-
您可以自己构造 API 调用以获取 JSON 响应。我能问一下您为什么需要 JSON 以及为什么帮助程序库没有给您所需的对象吗?
-
来自 Twilio 文档:“Json:如果您的函数返回有效的 Json,您应该能够通过 widgets.MY_WIDGET_NAME.parsed 访问它”
标签: php twilio twilio-api twilio-php