• PHP Openkm API List folders and documents Problem

  • We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #44447  by bedhoel
 
Hello i'm new using Openkm.
I'm already install Lates version Openkm profesional Trial.

i try the tutorial
https://www.openkm.com/wiki/index.php/P ... OpenKM_6.2
this tutorial List folders and documents

when i try this code i have found error
Code: Select all
<?php
  function printFolder($folder) {
    echo "[FOLDER] Path: ".$folder->path.", Author: ".$folder->author."<br>";
  }
 
  function printDocument($document) {
    echo "[DOCUMENT] Path: ".$document->path.", Author: ".$document->author.", Size: ".$document->actualVersion->size."<br>";
  }
 
  // Register WSDL
  $OKMAuth = new SoapClient('http://localhost:8080/OpenKM/services/OKMAuth?wsdl');
  $OKMDocument = new SoapClient('http://localhost:8080/OpenKM/services/OKMDocument?wsdl');
  $OKMFolder = new SoapClient('http://localhost:8080/OpenKM/services/OKMFolder?wsdl');
  $path = '/okm:root';
 
  // Login
  $loginResp = $OKMAuth->login(array('user' => 'okmAdmin', 'password' => 'admin'));
  $token = $loginResp->return;
  echo "Token: ".$token."<br>";
  echo "Path: ".$path."<br>";
 
  // List folders
  $getChildrenResp = $OKMFolder->getChildren(array('token' => $token, 'fldPath' => $path));
  $folderArray = $getChildrenResp->return;
 
  if ($folderArray) {
    if (is_array($folderArray)) {
      foreach ($folderArray as $folder) {
        printFolder($folder);
      }
    } else {
      printFolder($folderArray);
    }
  }
 
  // List documents
  $getChildrenResp = $OKMDocument->getChildren(array('token' => $token, 'fldPath' => $path));
  $documentArray = $getChildrenResp->return;
 
  if ($documentArray) {
    if (is_array($documentArray)) {
      foreach ($documentArray as $document) {
        printDocument($document);
      }
    } else {
      printDocument($documentArray);
    }
  }
 
  // Logout
  $OKMAuth->logout(array('token' => $token));
?>
This result code :
Token: 15f9ebf3-4ab3-48bd-932f-f9ea7e918211
Path: /okm:root

Fatal error: Uncaught SoapFault exception: [soap:Server] Fault occurred while processing. in C:\xampp\htdocs\web_dms\home.php:28 Stack trace: #0 C:\xampp\htdocs\web_dms\home.php(28): SoapClient->__call('getChildren', Array) #1 C:\xampp\htdocs\web_dms\home.php(28): SoapClient->getChildren(Array) #2 {main} thrown in C:\xampp\htdocs\web_dms\home.php on line 28
i want show my folder and document in OpenKM, previously i'm already search in google but i can't found this solution. I don't know how to fix it, help me thank's
 #44455  by jllort
 
Several things to take in consideration:
1- wiki is deprecated, you should not use it you should use https://docs.openkm.com/kcenter/
2- there're 2 php versions ( professional or community ), looking in the compatibility table you should use version 2.3.0 https://docs.openkm.com/kcenter/view/sdk4php/

What kind of test are you trying to do ? because sometimes is better you contact with us and sales & marketing can share with you a full demo online for a couple of weeks.
 #47118  by marcovilliams
 
Hello,
bedhoel wrote: Sun Jul 30, 2017 6:36 am Hello i'm new using Openkm.
I'm already install Lates version Openkm profesional Trial.

i try the tutorial
https://www.openkm.com/wiki/index.php/P ... OpenKM_6.2
this tutorial List folders and documents

when i try this code i have found error
Code: Select all
<?php
  function printFolder($folder) {
    echo "[FOLDER] Path: ".$folder->path.", Author: ".$folder->author."<br>";
  }
 
  function printDocument($document) {
    echo "[DOCUMENT] Path: ".$document->path.", Author: ".$document->author.", Size: ".$document->actualVersion->size."<br>";
  }
 
  // Register WSDL
  $OKMAuth = new SoapClient('http://localhost:8080/OpenKM/services/OKMAuth?wsdl');
  $OKMDocument = new SoapClient('http://localhost:8080/OpenKM/services/OKMDocument?wsdl');
  $OKMFolder = new SoapClient('http://localhost:8080/OpenKM/services/OKMFolder?wsdl');
  $path = '/okm:root';
 
  // Login
  $loginResp = $OKMAuth->login(array('user' => 'okmAdmin', 'password' => 'admin'));
  $token = $loginResp->return;
  echo "Token: ".$token."<br>";
  echo "Path: ".$path."<br>";
 
  // List folders
  $getChildrenResp = $OKMFolder->getChildren(array('token' => $token, 'fldPath' => $path));
  $folderArray = $getChildrenResp->return;
 
  if ($folderArray) {
    if (is_array($folderArray)) {
      foreach ($folderArray as $folder) {
        printFolder($folder);
      }
    } else {
      printFolder($folderArray);
    }
  }
 
  // List documents
  $getChildrenResp = $OKMDocument->getChildren(array('token' => $token, 'fldPath' => $path));
  $documentArray = $getChildrenResp->return;
 
  if ($documentArray) {
    if (is_array($documentArray)) {
      foreach ($documentArray as $document) {
        printDocument($document);
      }
    } else {
      printDocument($documentArray);
    }
  }
 
  // Logout
  $OKMAuth->logout(array('token' => $token));
?>
Thanks for share this details with share the tutorials link I use this code.
thanks again!

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.