我正在尝试使用Web应用程序发送短信。我发现API可以帮助我做到这一点,但是其文档不多。
我需要使用PHP发送请求。
最后,我已经使用JavaScript正确发送了请求。现在,我想对PHP进行同样的操作。
var Username="abcdefg"
var password="123456789"
var language="1"
var sender="mysenderid"
var Mobile= mobile
var message= "Dear name would you please give us your feedback about your last order click here "
$.post(`https://smsmisr.com/api/webapi/?Username=${Username}&password=${password}&language=${language}&sender=${sender}&Mobile=${Mobile}&message=${message}`, function (data){
console.log(data);
});
答案 0 :(得分:0)
在php中,您可以按照以下方式进行操作:
<?php
$request = new HttpRequest();
$request->setUrl('YOUR_END_POINT e.g. https://www.google.ca');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'Content-Type' => 'application/json; charset=utf-8',
'PARAM1' => '990d16da-31d9-4961-a340-e21caf0a13d7',
'PARAM2' => 'no-cache',
'app_version' => '0.0.0.1',
'app_name' => 'YOUR_APP_NAME'
));
$request->setBody('{
"ID" : "80E1CB93-52de-4cd1-abd9-5786e4e616c8",
"PHONE": "+14574544460",
"SIN": "027899876557",
"Auth" : "A",
"other": "othervalue"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
根据您的情况,使用:
'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8'