我创建了这个 cakePHP 函数来通过 infoBip 网关系统发送 SMS,但它似乎无法正常工作,因为错误代码一直给我空目的地。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。