PHP code example of akamai-open / edgegrid-auth

1. Go to this page and download the library: Download akamai-open/edgegrid-auth library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

akamai-open / edgegrid-auth example snippets


      // Library is ready to use
    

     

     

$auth = \Akamai\Open\EdgeGrid\Authentication::createFromEdgeRcFile('default', '/.edgerc');
$auth->setHttpMethod('GET');
$auth->setPath('/identity-management/v3/user-profile');

$context = array(
  'http' => array(
    'header' => array(
      'Authorization: ' . $auth->createAuthHeader(),
      'Content-Type: application/json'
    )
  )
);

$context = stream_context_create($context);

$response = json_decode(file_get_contents('https://' . $auth->getHost() . $auth->getPath(), null, $context));