• Problema creando documento con SDK PHP

  • Do you want to create a native client or integrate with third party applications: webservices are the solution.
Do you want to create a native client or integrate with third party applications: webservices are the solution.
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.
 #43597  by fisioemax
 
Traslado la pregunta a este apartado ya que es más correcta que donde la puse anteriormente.

El código me crea el documento en la carpeta del ordenador pero a la hora de llamar al método createDocument muestra los siguientes warning y no crea el documento dentro de OpenKM.
Code: Select all
<?php

include 'src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testCreateDocument() {
        try {

        	$archivo = fopen("datos.html", "w") or die("error creando fichero!");
			$txt = "<h1>Contenido completo en HTML...</h1>";
			fwrite($archivo, $txt);
			fclose($archivo);
	        $fileName = dirname(__FILE__) . '/datos.html';
            $document = new \openkm\bean\Document();
            $document->setPath('/okm:root/Prueba/datos.html');
            $doc = $this->ws->createDocument($document, file_get_contents($fileName));
            var_dump($doc);
        } catch (Exception $e) {
            var_dump($e);
        }
    }
}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testCreateDocument();
?>
Los warnings:
Code: Select all
Warning: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found in C:\xampp\htdocs\openkm\src\Httpful\Handlers\XmlHandler.php on line 42

Warning: simplexml_load_string(): NullPointerException: null in C:\xampp\htdocs\openkm\src\Httpful\Handlers\XmlHandler.php on line 42

Warning: simplexml_load_string(): ^ in C:\xampp\htdocs\openkm\src\Httpful\Handlers\XmlHandler.php on line 42
Muchas gracias.
 #43623  by sochoa
 
Hola muy buenos dias hay un bugs con el metodo createDocument del SDK de PHP lo estoy revisando

puede probar con el otro metodo:
Code: Select all
createDocumentSimple($docPath,$content);

public function testCreateDocumentSimple() {
        try {
            $fileName = dirname(__FILE__) . '/files/logo.png';
            $docPath = '/okm:root/SDK4PHP/logo.png';
            $document = $this->ws->createDocumentSimple($docPath, file_get_contents($fileName));
            var_dump($document);
        } catch (Exception $e) {
            var_dump($e);
        }
    }
Code: Select all
<?php

include 'src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testCreateDocumentSimple() {
        try {

        	$archivo = fopen("datos.html", "w") or die("error creando fichero!");
			$txt = "<h1>Contenido completo en HTML...</h1>";
			fwrite($archivo, $txt);
			fclose($archivo);
	        $fileName = dirname(__FILE__) . '/datos.html';
            $docPath = '/okm:root/Prueba/datos.html';
            $doc = $this->ws->createDocumentSimple($docPath, file_get_contents($fileName));
            var_dump($doc);
        } catch (Exception $e) {
            var_dump($e);
        }
    }
}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testCreateDocumentSimple();
?>
 #44757  by sochoa
 
Hola muy buenas noches.

El metodo createDocument se decidio quitarlo ya que el metodo createDocumentSimple hace lo mismo.

Esto cambio estara en la ver v1.1.2 del sdk4php

Saludos
 #44765  by jllort
 
En la documentación (https://docs.openkm.com/kcenter/) ya se encuentra disponible la versión 1.1.2 ( https://docs.openkm.com/kcenter/view/sdk4php-1.1.2/ ). Tal y como te indicaba mi compañero hemos decidido deprecar este método, porque entendemos que no tiene sentido a nivel del API.

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.