• OKMDocument -> getProperties()

  • 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.
 #21331  by olsonea
 
Is the output (Document) of the getProperties method an object? What is the property name for the MIME type?

get_object_vars() should return all of the object properties in an array, and array_values() should list the values of the array, but the returned output is "Array". Not sure if that is a failure of my php coding skills, or if I'm misinterpreting the return type of getProperties. Any help is appreciated.
Code: Select all
<?php
// Register WSDL
$OKMAuth = new SoapClient('http://OpenKM:8080/OpenKM/services/OKMAuth?wsdl');
$OKMDocument = new SoapClient('http://OpenKM:8080/OpenKM/services/OKMDocument?wsdl');
// Login
$loginResp = $OKMAuth->login(array('user' => 'okmAdmin', 'password' => 'admin'));
$token = $loginResp->return;

//open document test
$docPath = '/okm:root/Customer Docs/olsonea@gmail.com/Invoice-0000034.pdf';

//get document properties
$docProperties = $OKMDocument->getProperties(array('token' => $token, 'docPath' => $docPath));
$properties = get_object_vars($docProperties);
echo array_values($properties);

// Logout
$OKMAuth->logout(array('token' => $token));
?>
 #21332  by olsonea
 
The error was in my php code. var_dump() will return the object variables.
Code: Select all
<?php
// Register WSDL
$OKMAuth = new SoapClient('http://OpenKM:8080/OpenKM/services/OKMAuth?wsdl');
$OKMDocument = new SoapClient('http://OpenKM:8080/OpenKM/services/OKMDocument?wsdl');
// Login
$loginResp = $OKMAuth->login(array('user' => 'okmAdmin', 'password' => 'admin'));
$token = $loginResp->return;

//open document test
$docPath = '/okm:root/Customer Docs/olsonea@gmail.com/Invoice-0000034.pdf';

//get document properties
$docProperties = $OKMDocument->getProperties(array('token' => $token, 'docPath' => $docPath));
$properties = get_object_vars($docProperties);
echo var_dump($properties);

// Logout
$OKMAuth->logout(array('token' => $token));
?>
 #21333  by olsonea
 
Hmm... well, the output doesn't seem to be an object, but rather an array with a single element. Still trying to extract only the mimeType.
 #21334  by olsonea
 
Ok, I got it finally. getProperties does return a Document object, but mimeType needs to be accessed like this:
Code: Select all
//get document properties
$docProperties = $OKMDocument->getProperties(array('token' => $token, 'docPath' => $docPath));
echo $docProperties->return->mimeType;
 #21365  by olsonea
 
I have seen the PHP client examples. They did not show how to get a specific parameter from Document object returned by the getProperties method however, nor the schema for the Document class. I had to work that out on my own.
 #21393  by jllort
 
It's shown on examples but not on all, for example here:
Code: Select all
$createResp = $OKMDocument->create(array('token' => $token, 'doc' => $doc, 'content' => file_get_contents($file)));
  $newDoc = $createResp->return;
  echo "[DOCUMENT] Path: ".$newDoc->path.", Author: ".$newDoc->author.", Size: ".$newDoc->actualVersion->size."<br>";

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.