PHP code example of akamai-open / edgegrid-client

1. Go to this page and download the library: Download akamai-open/edgegrid-client 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-client example snippets




// Library is ready to use

    $client = \Akamai\Open\EdgeGrid\Client::createFromEdgeRcFile('{credentials_section_name}', '{path/to/.edgerc}');

    // Use $client just as you would \Guzzle\Http\Client
    $response = $client->get('/identity-management/v3/user-profile');
    

    $client = new Akamai\Open\EdgeGrid\Client([
    'base_uri' => 'https://akab-h05tnam3wl42son7nktnlnnx-kbob3i3v.luna.akamaiapis.net'
    ]);

    $client_token = 'akab-c113ntt0k3n4qtari252bfxxbsl-yvsdj';
    $client_secret = 'C113nt53KR3TN6N90yVuAgICxIRwsObLi0E67/N8eRN=';
    $access_token = 'akab-acc35t0k3nodujqunph3w7hzp7-gtm6ij';

    $client->setAuth($client_token, $client_secret, $access_token);

    // use $client just as you would \Guzzle\Http\Client
    $response = $client->get('/identity-management/v3/user-profile');
    


ent = \Akamai\Open\EdgeGrid\Client::createFromEdgeRcFile('default');

// use $client just as you would \Guzzle\Http\Client
$response = $client->get('/identity-management/v3/user-profile');

echo $response->getBody();


ent = \Akamai\Open\EdgeGrid\Client::createFromEdgeRcFile('default');

$headers = [
'Accept' => 'application/json',
];

$response = $client->get('/identity-management/v3/user-profile?authGrants=true&notifications=true&actions=true', $headers);

echo $response->getBody();


ent = \Akamai\Open\EdgeGrid\Client::createFromEdgeRcFile('default');

$headers = [
  'Accept' => 'application/json'
];

$response = $client->get('/identity-management/v3/user-profile', $headers);

echo $response->getBody();


ent = \Akamai\Open\EdgeGrid\Client::createFromEdgeRcFile('default');

$headers = [
    'Content-Type' => 'application/json',
    'Accept' => 'application/json'
  ];

$body = [
  'json' => [
    'contractType' => 'Billing',
    'country' => 'USA',
    'firstName' => 'John',
    'lastName' => 'Smith',
    'phone' => '3456788765',
    'preferredLanguage' => 'English',
    'sessionTimeOut' => '30',
    'timeZone' => 'GMT'
  ]
];

$response = $client->put('/identity-management/v3/user-profile/basic-info', $body, $headers);

echo $response->getBody();