0

I have built templates to export my EE site as a JSON API. I am trying to set up a static site generator deploying to Netlify.

What I want is to run a curl command when I create a new entry or update an old one to trigger a build and deploy by Netlify.

curl -X POST -d '{}' https://api.netlify.com/build_hooks/XXXXXXXXXXXXXXX

I am pretty familiar with PHP but zero experience with EE. What would be the best way to achieve this?

Thanks.

1

You'll want to write an Extension that is fired by this extension hook:

https://docs.expressionengine.com/latest/development/extension-hooks/model/channel-entry.html#before_channel_entry_saveentry-values

Extension docs:

https://docs.expressionengine.com/latest/development/extensions.html

When all set up, you'll have a method in your Extension class that is called whenever you save a new entry or update an existing one. That method will look like this:

public function my_extension_method($entry, $values)
{
    // Here I would recommend instantiating a Curl library to perform your curl actions
}

Please review the docs and let us know if you get stuck, I could probably expand my example if needed.

1
  • I will give this a shot. Sounds like it will do exactly what I want. Thanks!
    – ewarrin
    May 30 '19 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.