× Requests and support related to jBackend.

POST to another url (a server outside my Joomla)

  • igorsgm
  • Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 7 months ago #5668 by igorsgm
Hello guys, I'm brand new with RESTFul api's and also with jBackend... I'm wondering some points:

- Which is the best way to send data via post, to external URL using JBackend? (cURL, AJAX...). Does JBackend already allows it?

- There is an example of plugin which already do such thing?

- If not, what should be the right way to build one like this? (I know the HelloWorldPlugin is the first step, but what would be the main logic).

An example of what I want:
I have a custom component in a Joomla installation (the same which JBackend is installed), and every time some data is updated in these component, I must send a JSON to specific external URL (which does not have JBackend, but have another API).


I hope have been clear and sorry for any misunderstanding.
Thanks in advance.

Please Log in or Create an account to join the conversation.

More
7 years 7 months ago - 7 years 7 months ago #5669 by admin
Hi,
I understand exactly what you need and jBackend is NOT the best option to accomplish it. jBackend receives data from external systems, you need to send data to external systems.

The simplest way to get this is to create a custom plugin that "hooks" an event and send the data received from the event payload to the xterna system. The component should trigger the event every time something of interest happens. An event could be generated with a simple line when is not already available, example:
// *** BEGIN CUSTOM CODE ***
// Custom code for trigger an event
JPluginHelper::importPlugin('<plugintype>');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('on<customEventName>', array($data, $var1, $var2, ..., $varN));
// *** END CUSTOM CODE ***

Kind regards,
Luigi
Last edit: 7 years 7 months ago by admin.
The following user(s) said Thank You: igorsgm

Please Log in or Create an account to join the conversation.

  • igorsgm
  • Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 7 months ago #5670 by igorsgm
Hi Luigi, thanks for your answer.

I need to recieve data from external systems also, that's one reason I bought JBackend. And by first view, it looks like awesome.

Do you think is better to create a plugin separated from JBackend or can I integrate it as a new JBackend module (such as user/content module)? (doing what you said)
And if I would do that, the best way to trigger this event is using php curl?

By the way, do you know another tool which accomplish what I'm needing?

Sorry for tons of questions, but I have short time to finish this demand.

Thanks in advance!

Please Log in or Create an account to join the conversation.

More
7 years 7 months ago #5671 by admin
To answer your question, the trigger to sent or the sending itself should happen in the extension you need to integrate. So, as example, if you want to send data when a jBackend plugin receives some data, it is correct to insert the event/action in the jBackend plugin itself. If you, instead, want to send data when, as example, a user registers, because there is already an event triggered for this, you should just create a plugin that "hooks" the event and send the data. I already wrote an example on how to raise an event n case you don't have one existing to hook.

I cannot add more without to have a more detailed picture of what you need, but if you need more info, feel free to send me a PM at info(at)selfget.com.

Kind regards,
Luigi

Please Log in or Create an account to join the conversation.

Time to create page: 0.150 seconds