我从这里尝试了下面的代码, 但是有一个错误,叫做没有找到 HttpRequest 类。我正在使用 php 版本 5.6.8(xampp v3.2.1)。任何人请帮助我。
<?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 sfdsdf==' // name&password
));
$request->setBody('{
"from":"test", //from
"to":"000", // number
"text":your verification code is = 000."
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}