Get app access token with PHP


I’m trying to refresh my access token with that PHP script, shown like here:

my php code to send the POST request is :

$client_id = 'XXX';
$client_secret = 'XXX';

$url = '';
$data = array('client_id' => $client_id, 'client_secret' => $client_secret, 'grant_type' => 'client_credentials');

$options = array(
	'http' => array(
		'header' => "Content-type: application/x-www-form-urlencoded\r\n",
		'method' => 'POST',
		'content' => http_build_query($data)
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) {}


But I get this “error”:


The script worked 2 month ago. did they changed something ?

Ideally you would be using cURL here instead of file_get_contents with a stream.

This would suggest your host is now blocking file_get_contents ability to make HTTP requests

thanks works now!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.