[SOLVED] Can't make PHP integration example work.

Integration questions/issues
Posts: 13
Joined: Mon Dec 14, 2015 5:40 pm

[SOLVED] Can't make PHP integration example work.

Post by dandanielw » Wed Jan 13, 2016 7:42 pm

Hi, I've been trying for some days already to make the PHP integration example work without success yet.
I need to get this working in a few days so I request your help.
First of all I describe my current setup to contextualize.

I'm working on an ubuntu linux

Code: Select all

➜  ~  uname -a
Linux daniel 3.19.0-33-generic #38~14.04.1-Ubuntu SMP Fri Nov 6 18:17:28 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
I installed the OnlyOffice through docker like this:

Code: Select all

sudo docker run -i -t -d -p 880:80 -p 4443:443 --name onlyoffice \
    -v /opt/onlyoffice/Logs:/var/log/onlyoffice  \
    -v /opt/onlyoffice/Data:/var/www/onlyoffice/Data  onlyoffice/documentserver
I downloaded the integration example from http://api.onlyoffice.com/app_data/PHP%20Example.zip

And I setup the the config.php just like it's suggested in the reply for this post viewtopic.php?f=9&t=5740

This is how my config file looks like (only the parts I modified, the other settings are left as they came from the example:

Code: Select all

define('WEB_ROOT_URL', 'http://localhost:8080');
$GLOBALS['STORAGE_PATH'] = "archivos";
localhost:8080 is the socket for the webserver that will serve and integrate the onlyoffice service
and is the socket of the docker container which is actually the onlyoffice server.

So this is what happens:

When I enter http://localhost:8080 I can visuallize correctly the index.html where I see the links for the Sample doc, spreadsheet and presentation, together with the upload option.

When I upload a file, the file is uploaded correctly to the localhost:8080 server as I can see it in the designated folder, and the UI says everything is ok. and the response to the webeditor-ajax.php confirms it

Code: Select all

now, if I want to open a file for viewing or editing comes the problem.
From the success upload modal windows I click on the edit button and it tries to open the following URL in a new windows:

but I get 2 alert windows (after waiting some long seconds) :

The file cannot be accessed right now
Download failed. Press OK to return to document list.

Almost the same thing happens when I try to open a Sample file, but I only the the second message ( Download failed ) .

Can someone give me a hand with this? I really need to get this working.

Thanks a lot.

I noticed that the problem was not the server itself but the file_get_contents(...) function in combination with the http server.
I noticed the function was throwing a Warning "failed to open stream: HTTP request failed!" so after a few unsuccessful workarounds I wondered if php's built in server was causing the problem and it actually that was it. Set up a http server instead of using php -s localhost:8080 the it's solved.

Conclusion: BEWARE of PHP's build-in server.