<?php
$credentials = "aaaaaaaaaaaaa:bbbbbbbbbbbbbbb";
$ch = curl_init();
$options = array(
CURLOPT_URL => 'https://agoodsite.com/connect2/agoodtoken',
CURLOPT_POST => 1,
CURLOPT_HEADER => false,
// Set the auth type as `Basic`
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
// Set login and password for Basic auth
CURLOPT_USERPWD => $credentials,
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Content-Type: application/x-www-form-urlencoded'
),
// To send additional parameters in the POST body
CURLOPT_POSTFIELDS => "mygrant_type=myclient_credentials"
);
curl_setopt_array($ch, $options);
// This is the response for your request
$result = curl_exec($ch);
// This is the response status code (if you are interested)
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $result;
echo $status_code;
?>