Error in API

Hi,

I am using hubspot contact API on postman its working fine. But in php i am getting error. I am posting code and its response kidly let me know the solution.

PHP CODE

$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => ‘https://api.hubapi.com/crm/v3/objects/contacts?limit=10&properties=firstname&hapikey=XYZ’,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => ‘’,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => ‘GET’,
));
$response = curl_exec($curl);
curl_close($curl);
$agents = json_decode($response);
echo ‘<pre>’; print_r($agents); die(‘Hello-world’);
RESPONSE

stdClass Object
(
 [status] => error
 [message] => This app hasn't been granted all required scopes to make this call. Read more about required scopes here: https://developers.hubspot.com/scopes.
 [correlationId] => xyz
 [errors] => Array
 (
 [0] => stdClass Object
 (
 [message] => One or more of the following scopes are required.
 [context] => stdClass Object
 (
 [requiredScopes] => Array
 (
 [0] => e-commerce
 [1] => tickets
 [2] => crm.objects.goals.read
 [3] => media_bridge.read
 [4] => crm.objects.custom.read
 [5] => crm.objects.custom.write
 )

 [requiredGranularScopes] => Array
 (
 [0] => crm.objects.contacts.write
 [1] => crm.objects.line_items.read
 [2] => crm.objects.line_items.write
 [3] => crm.objects.quotes.write
 [4] => crm.objects.quotes.read
 [5] => crm.objects.contacts.read
 [6] => crm.objects.companies.read
 [7] => crm.objects.deals.read
 [8] => crm.objects.deals.write
 [9] => crm.objects.companies.write
 )

 )

 )

 )

API Keys have been deprecated because they allow super admin access which is bad. Create a private app in your account and you can set your granular required scopes and it will give you an access token to use in your programming.