PHP Openkm API List folders and documents Problem

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.
Post Reply
bedhoel
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: Sun Jul 30, 2017 1:51 am

PHP Openkm API List folders and documents Problem

Post by bedhoel » 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));
?>
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

jllort
Moderator
Moderator
Posts: 10501
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: PHP Openkm API List folders and documents Problem

Post by jllort » Mon Jul 31, 2017 2:52 pm

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.

kamal
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: Mon Jun 18, 2018 7:56 am

Re: PHP Openkm API List folders and documents Problem

Post by kamal » Mon Jun 18, 2018 9:06 am

Hi,

im using PHP SDK 1.1.2 OPENKM COMMUNITY 6.3

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

jllort
Moderator
Moderator
Posts: 10501
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: PHP Openkm API List folders and documents Problem

Post by jllort » Wed Jun 20, 2018 4:38 pm


marcovilliams
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: Tue Dec 04, 2018 12:32 pm

Re: PHP Openkm API List folders and documents Problem

Post by marcovilliams » Tue Dec 04, 2018 12:40 pm

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!

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests