I’m new to WordPress and I have to do the following: on publishing a new article on WordPress I also want to trigger an "event" that take the article data (text, images) and send them to an external API (HTTP post request).
Searching on Google I found some plugin (e.g. wpgetapi.com) that should allow to call an external API but in my understanding it’s more to GET data from an external API to build a WordPress article.
What I would like to have is a place where put some custom logic to trigger during the "publishing event" so that I can popolate the API call using article data.
NOTE: if it’s not possible to intercept the publishing event, it would be ok also to manually push the article data to the external API.
2
Answers
There are a few plugins that can help you to do this, such as:
Once you have installed and activated one of these plugins, you can use it to create a custom logic that is hooked to the publish_post action.
You could also use something like Zapier, to create a "Zap" that triggers a POST request to an external API when a new article is published
If you don’t want to use a plugin, you can also add your own custom code to intercept the publishing event and send the article data to the external API.
Example:
You can use Gato GraphQL (free) with the HTTP Client addon (paid): Retrieving data from an external API