I am trying to send an HTTP request to an URL using the below code,but keep getting error
(file_get_contents(http://localhost:81/Help/Api/POST-SMS): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error)
, any idea? Thank in advance
<?php
$url = 'http://localhost:81/Help/Api/POST-SMS';
$data = array('message' => 'hi', 'mobile' => '12345678');
$options = array(
'http' => array(
'header' => "Content-type: application/json",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }
var_dump($result);
?>