Calling external PHP after event

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
schimanke
Regular
Posts: 161
Joined: Mon Jan 07, 2008 4:38 pm
Location: Hameln, Germany
Contact:

Calling external PHP after event

Post 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!
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Calling external PHP after event

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
schimanke
Regular
Posts: 161
Joined: Mon Jan 07, 2008 4:38 pm
Location: Hameln, Germany
Contact:

Re: Calling external PHP after event

Post by schimanke »

Ouch... That's quite a lot of work for what I am trying to do. :-) So maybe later. Thanks for the explanation!
Post Reply