Good afternoon everyone, I have the following problem: I have to consume from a WS that returns me a Token, to use authentication in other WS. To get this token I have to send parameters via POST and I get a JSON with the token. Can I do this using file_get_contents? I tried with the code below, removed from the PHP documentation, and it did not work.
$postdata = http_build_query(
array(
'var1' => 'some content',
'var2' => 'doh'
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents('http://example.com/submit.php', false, $context);
But my result is only giving false and displaying the error: "file_get_contents (): php_network_getaddresses: getaddrinfo failed: Name or service not known in (...)"
Does anyone know how to solve it?