Communication between two apps in NextCloud

How to connect two programs in Next Cloud?

For example, put a photo in the files section and it will be shown in the program I made for NextCloud.

There are multiple ways to accomplish this.

In the front-end its generally easier, as you can just create a global Javascript object which other apps can use. For example your app can use to request the Viewer app to open a file.

In the backend, things get a bit tricker.

If you are integrating with a core nextcloud app or service then you can integrate with it using the server public API interfaces. So in your specific example the photos app can simply request the files from the API directly.

Roughly, something like this:

$userFolder = $this->rootFolder->getUserFolder($userId);

foreach ($userFolder->getDirectoryListing() as $node) {
  // Check if node is an image...
  // ...

If you need to integrate with an app that is not part of the public API then there are multiple approaches:

  • If the app is designed with integration in mind, it will offer Events that you can use for integrating safely with the app. (Example)
  • A more risky approach is to access the apps internals directly. For example, the Collectives app directly interfaces with the Circles code. (Example)
  • Other apps may offer REST APIs which can be used. Deck and Tables come to mind.

I am talking to @christianlupus about on this subject on this topic : How to work the OAuth2 with Nextcloud? - #17 by z4k

The subject is a little complicated.

For now, Nextcloud doesn’t an official response.