我正在设置 Twilio 并尝试向我的个人手机发送一条简单的短信。但我得到的只是标题中的这个错误+这发生在第 127 行的 Services/Twilio/Resource.php 上:
public function __toString() {
$out = array();
foreach ($this as $key => $value) {
if ($key !== "client" && $key !== "subresources") {
$out[$key] = (string)$value; <----------------HERE
}
}
return json_encode($out);
}
我在控制器上的代码如下所示:
$client = new Services_Twilio($AccountSid, $AuthToken);
try {
foreach($listUsers as $user){
$sms = $client->account->sms_messages->create(
$phone, // From this number
$user['phone'], // To this number
$message
);
}
$data['results'] = "success";
$data['message'] = "Your message have been sent successfully";
echo json_encode($data);
} catch (Services_Twilio_RestException $e) {
$data['results'] = "error";
$data['message'] = $e->getMessage();
echo json_encode($data);
}
我现在坐了几个小时,似乎无法弄清楚问题所在。也许有人用过这个 Twilio,至少可以给我一个提示。
整个错误:
PHP Catchable fatal error: Object of class Services_Twilio_TinyHttp could not be converted to string in ../Services/Twilio/Resource.php on line 127, referer: