Page 1 of 1

PHP Openkm API List folders and documents Problem

PostPosted:Sun Jul 30, 2017 6:36 am
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

Re: PHP Openkm API List folders and documents Problem

PostPosted:Mon Jul 31, 2017 2:52 pm
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.

Re: PHP Openkm API List folders and documents Problem

PostPosted:Mon Jun 18, 2018 9:06 am
by kamal
Hi,

im using PHP SDK 1.1.2 OPENKM COMMUNITY 6.3

How can i use REST API to list all folders and Document ..

Re: PHP Openkm API List folders and documents Problem

PostPosted:Wed Jun 20, 2018 4:38 pm
by jllort

Re: PHP Openkm API List folders and documents Problem

PostPosted:Tue Dec 04, 2018 12:40 pm
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!