我创建了这个cakePHP函数来通过infoBip网关系统发送短消息,但是它似乎不能工作,因为错误代码一直给我空的目的地。to=>null这是他们的文档链接
public function sendSMS($recipient, $sender, $message) {
$url = 'https://api.infobip.com/sms/1/text/single';
$to = explode(',', $recipient);
$data = ["to" => $to, "from" => $sender, "text" => $message];
$postData = array("messages" => array($data)); //message to send to gateway
// encoding object
$postDataJson = json_encode($postData);
$request = array('header' => array(
'accept' => 'application/json',
'content-type' => 'application/json',
'authorization' => 'Basic #################'
));
$response = $this->cakeSocket($url, $postDataJson, $request);
pr($postDataJson);
($response->body());
return $response->body();
//$this->redirect(array('action' => 'index'));
}请参阅附件,我发送的变量和从网关获得的错误响应。

请告知我做错了什么,因为系统没有收到我的变量。谢谢。学习使用CakePHP。
发布于 2016-09-02 12:45:24
文件上说:
{
"from":"InfoSMS",
"to":"41793026727",
"text":"My first Infobip SMS"
}你发送数组"to":["41793026727"]
将$recipient分解为数组$to,所以尝试"to" => $to[0],
https://stackoverflow.com/questions/39290770
复制相似问题