I'm trying to get a JSON object with PHP. When I try it with Jquery it works fine, but when I try the same with PHP, it returns me a timetout message.
Jquery code:
$(document).ready(function(){
$.post("https://xxxxx/mig_search", {Keywords: 'test'}, function(result){
var myObj = JSON.parse(result);
$("body").html(result);
});
});
PHP code:
$url = "https://xxxxx/mig_search";
$postdata = http_build_query(
array(
'Keywords' => 'teste',
)
);
$options = array('http' =>
array(
'method' => 'POST',
'header' => 'User-Agent: request',
'content' => $postdata,
));
$ctx = stream_context_create($options);
$result = file_get_contents($url, false, $ctx);
if (!empty($result)) {
echo $result;
} else {
echo "Nao funcionou!";
}
die;