如何在php中使用infobip api发送短信?

时间:2015-07-23 08:57:58

标签: php json api

使用Infobip sms网关时遇到问题。当我执行此代码时,我不知道下面的代码有一个错误叫做没有找到HttpRequest类。任何人请帮助我。

<?php

$request = new HttpRequest();
$request->setUrl('https://api.infobip.com/sms/1/text/single');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'accept' => 'application/json',
  'content-type' => 'application/json',
  'authorization' => 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
));

$request->setBody('{  
   "from":"InfoSMS",
   "to":"41793026727",
   "text":"Test SMS."
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

0 个答案:

没有答案