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 = \Akamai\Open\EdgeGrid\Authentication([
'base_uri' => 'https://akab-h05tnam3wl42son7nktnlnnx-kbob3i3v.luna.akamaiapis.net'
]);
$auth-> setHost('https://akab-h05tnam3wl42son7nktnlnnx-kbob3i3v.luna.akamaiapis.net');
$client_token = 'akab-c113ntt0k3n4qtari252bfxxbsl-yvsdj';
$client_secret = 'C113nt53KR3TN6N90yVuAgICxIRwsObLi0E67/N8eRN=';
$access_token = 'akab-acc35t0k3nodujqunph3w7hzp7-gtm6ij';
$auth-> setAuth($client_token, $client_secret, $access_token);
h = \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));