Page 1 of 1

Calling external PHP after event

Posted: Tue Dec 04, 2012 4:22 pm
by schimanke
Hi there,

just a short question to start with. Is it possible to call an external php script on a certain event, for example when a prepared blog post goes online at a time in the future? If yes, how do I accomplish this?

Scenario:
- prepare a blog post with a publishing date in the future
- when the post goes live > call a given php script on an external server with the title of the blog post as a parameter

Any ideas? Thanks in advance!

Re: Calling external PHP after event

Posted: Wed Dec 05, 2012 1:34 pm
by garvinhicking
Hi!

Yes and no.

s9y has event hooks, that you can create plugins for that hook into those events. Upon those events, you can then also include foreign PHP scripts.

Look into any of the existing event plugins that come close to what you want to do (like serendipity_event_mailer), that also hook into the blog entry publish queue and then create your own plugin, that will then load the PHP code you want.

HOWEVER. There is no event when a scheduled entry goes online. This is no event, becaue the SQL query simply uses the servers timezone, and the entry simply magically appears once that threshold is reached. So you need to write your own event that analyzes the timestamp and see if certain entries became published. You then need a database table where you store which entries have already been "seen", and if its a new entry, now you can perform your action.

So yes, this is definitely doable, but this definitely needs you to understand PHP and SQL coding. :-)

Regards,
Garvin

Re: Calling external PHP after event

Posted: Thu Dec 06, 2012 1:41 pm
by schimanke
Ouch... That's quite a lot of work for what I am trying to do. :-) So maybe later. Thanks for the explanation!