<?php

//get data 

$doc = $_GET['doc'];
$testcode = $_GET['test'];

if($doc == 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZXRqbGprN2huM2dpdmNpemR6d2NiaGhzbHk4NHB4MTZfdHV0b3JpYWxfYnVja2V0L09NQS0wMDQtMDAxLUFFQy1BLUJJTS0wMC0wMDA2Lm53Yw'){
    $doc = 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZXRqbGprN2huM2dpdmNpemR6d2NiaGhzbHk4NHB4MTZfdHV0b3JpYWxfYnVja2V0L2NhcnBhcmtfZXBveHkubndk';
}
/*
if($testcode ==null){
    header("Location: http://audwan.info");
}
*/
$id = $_GET['id'];

if($id == null)
    $id = -1;
// url connection 
$url = "https://developer.api.autodesk.com/authentication/v1/authenticate"; 


// client id 

//$clientid = 'GrHDUPiHb3wABppjuh0h6l3aozeEhGfD';
// client password 

//$clientpass = 'pGdW9xt5Qv8Mddu0';


$clientid = 'nUpJrtUne7IK6xx81rvsAZBWQJ9FWGMi';
// client password 

$clientpass = 'PUKgDbRPvoy3A82s';

// scope as below.

/*
'scope=data:read'
    -d 'scope=data:write'
    -d 'scope=data:create'
    -d 'scope=bucket:read'
    -d 'scope=bucket:create'
*/


// scope 

$scope = 'scope=bucket:create%20data:write%20bucket:read%20viewables:read%20data:read';


$headers = array('Content-Type: application/x-www-form-urlencoded');

$auth = 'client_id=' . $clientid . '&client_secret=' . $clientpass . '&grant_type=client_credentials&' . $scope;

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL,$url); 
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

curl_setopt($ch, CURLOPT_POSTFIELDS, $auth); 
// turn off the echo 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);


if (curl_errno($ch)) { 
    print "Error: " . curl_error($ch); 
} else {
    
    $result = json_decode($data,true);
    
    
    
} 
curl_close($ch);

?>