Skip to content

Instantly share code, notes, and snippets.

@ismasan
Forked from juque/curl_php_example.php
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismasan/8dac54b92e0648dc69b3 to your computer and use it in GitHub Desktop.
Save ismasan/8dac54b92e0648dc69b3 to your computer and use it in GitHub Desktop.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://auth.bootic.net/oauth/token");
// Reemplazar client_id:client_secret por credenciales de aplicación
curl_setopt($ch, CURLOPT_USERPWD, "client_id:client_secret");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials&scope=admin");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
// Parsea JSON
$data = json_decode($server_output);
// El token
$access_token = $data->{'access_token'};
print_r($access_token);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment