-1

I am trying to send SMS using my web app. I found API that helps me to do that, but its documentation is poor.

What I need is to send the request using PHP.

Finally, I have sent the request correctly using JavaScript. Now I want to do the same with 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);
});
MauriceNino
  • 6,214
  • 1
  • 23
  • 60
amr magdy
  • 53
  • 9

1 Answers1

0

In php, you can do it like below:

<?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;
}

In your case, use:

'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8'
slon
  • 1,002
  • 1
  • 8
  • 12