Page 1 of 1

OKMDocument -> getProperties()

PostPosted:Mon Feb 11, 2013 9:55 pm
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));
?>

Re: OKMDocument -> getProperties()

PostPosted:Mon Feb 11, 2013 10:01 pm
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));
?>

Re: OKMDocument -> getProperties()

PostPosted:Mon Feb 11, 2013 10:49 pm
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.

Re: OKMDocument -> getProperties()

PostPosted:Tue Feb 12, 2013 12:09 am
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;

Re: OKMDocument -> getProperties()

PostPosted:Thu Feb 14, 2013 2:37 pm
by jllort
I do not know if you take a look before the examples of http://wiki.openkm.com/index.php/PHP_cl ... OpenKM_6.2

Re: OKMDocument -> getProperties()

PostPosted:Thu Feb 14, 2013 2:43 pm
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.

Re: OKMDocument -> getProperties()

PostPosted:Fri Feb 15, 2013 5:40 pm
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>";