App HTTP Web Request


I made a logging app, I need to make this app send the logs to another URL beside logging, I’m not much familiar with NextCloud environment, so does there PHP function stream_context_create() & file_get_contents() work on a NextCloud app?

I already tried them with the API GET remote.php/dav/files/user/path/to/file and worked fine at netbeans


the NextCloud server is installed on a Linux server, I tried the cURL command on the Linux server’s terminal which was
curl -u user:password-X PROPFIND serverIpAddress/remote.php/dav/files/user/ but it didn’t work, it took to much time then returned time out error, but I have tried the same cURL command on the curl.exe on windows, it worked fine and returned the files and folders for the specified user, what could be the problem?

also the code above (PHP http request code) I added it at my app, but in the logs I got the error
file_get_contents(http:\/\/server\/remote.php\/dav\/files\/user): failed to open stream: Connection timed out
any idea?

Have you seen that?

actually I don’t want to make any operation on files, just broadcasting files activities, so I was just testing against any API, so I tried the API at this, which it should return the user’s files and folders, I got an error at the app, so I tried to send request directly using cURL on the Linux terminal, same thing, then tried it on the windows and then it succeeded.

so now I’m not sure, is this error because the http requests and blocked from within NextCloud server, or only NextCloud APIs and not runnable from the server itself?

I see. Sorry, I can not help with that.
Just noticed that in your cURL command there is a space missing between password and -X. Maybe that is the reason for the command not working as expected?

Thank you for the answer :slight_smile:
yeah that was a typo here on this thread, but I made sure of the command when I tested it

it seems I was passing the URL incorrect, I was passing the IP Address of the server from the server itself, so I changed it to http://localhost/remote.php/dav/files/user/ and it worked using cURL and the error isn’t showing at the app

1 Like