Issue with integration of ShareFile API with my web application on phh, item ID not gatting after run the API

  • 1
  • Problem
  • Updated 7 months ago
Dear Sir/Madam, we are working on integration of ShareFile API with my web application on php, but we are having issue with the item ID of files, that is we are not able to see the item/item ID in clients folder once run the API file, can anyone please help me as soon as possible??
Photo of Vick

Vick

  • 18 Posts
  • 0 Reply Likes

Posted 7 months ago

  • 1
Photo of Ross Bender

Ross Bender

  • 58 Posts
  • 10 Reply Likes
Can you post more detail please? Where are you looking for the ID and not seeing it?
Photo of Vick

Vick

  • 18 Posts
  • 0 Reply Likes
Dear Ross,

Thank you for reply.

I am getting below issues while calling api

1. I am unable to get "Shared folder  and child folders"

2.I am getting "personal folder and child folders" but cant access files in child folder.

Those two are my issues. I have provided my code below please check it once.

function authenticate($hostname, $client_id, $client_secret, $username, $password) {
    $uri = "https://".$hostname."/oauth/token";

   //echo "POST ".$uri."\n";
 
    $body_data = array("grant_type"=>"password", "client_id"=>$client_id, "client_secret"=>$client_secret,
                  "username"=>$username, "password"=>$password);
    $data = http_build_query($body_data);
     
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $uri);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_VERBOSE, FALSE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/x-www-form-urlencoded'));
 
    $curl_response = curl_exec ($ch);
 
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $curl_error_number = curl_errno($ch);
    $curl_error = curl_error($ch);
 
    //echo $curl_response."\n"; // output entire response
    //echo $http_code."\n"; // output http status code
     
    curl_close ($ch);
    $token = NULL;
//echo "<br> Print value -".$http_code; echo "<br/> After Value ";
    if ($http_code == 200) {
        $token = json_decode($curl_response);
        //print_r($token); // print entire token object
    }
//echo " <br> ".$token; exit;
    return $token;
}

function get_folder_with_query_parameters($token, $item_id) {
    $uri = "https://".get_hostname($token)."/sf/v3/Items(".$item_id.")?\$expand=Children&...;
    echo "GET ".$uri."\n";
 
    $headers = get_authorization_header($token);
 
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $uri);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_VERBOSE, FALSE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
 
    $curl_response = curl_exec ($ch);
     
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $curl_error_number = curl_errno($ch);
    $curl_error = curl_error($ch);
 
    //echo $curl_response."\n"; // output entire response
    echo $http_code."\n"; // output http status code
 
    curl_close ($ch);
 
    $root = json_decode($curl_response);
    //print_r($root); // print entire json response
     
    // only Id, Name are available here, because thats all that was requested
    echo $root->Id." ".$root->Name." "."\n";
    if (property_exists($root, "Children")) {
        foreach($root->Children as $child) {
            echo $child->Id." ".$child->CreationDate." ".$child->Name."\n";
        }
    }
}
 


 
$token = authenticate($hostname, $client_id, $client_secret, $username, $password);

$item=get_folder_with_query_parameters($token,'fohd08e9-3403-4d45-a31d-48b0869b6a0d');
 
 echo " <h1>Item Details</h1gm> -- <pre>";
 print_r($item);
 echo "</pre>";
 
---------------------------------------------------------------------------------------------------

please check it once.