Basically I have a node type which I've named "rss". Its purpose is exactly as I'm sure you guessed, all of these nodes are available as an rss view at a specific url (ex: http://mysite/rss/feed).

When a node of that type gets created (or updated I suppose) I need to make an http request to a specific url (the details to that are irrelevant to this question).

So lets say I create a new "rss" post on my drupal site, after it gets submitted I need an http request to the url ex: http://myapplication/blog?status=fetch

I know that I can make such a request happen with the visit url function in actions core module, and "trigger" it on node creation (not of a specific type though) but I think it does exactly that, and actually VISITS the url, whereas I just need it to make a curl type request.

I'm also using the scheduler module, so posts of this type can be scheduled, so I would need to trigger the action in sync with the schedule, if it is scheduled to be posted at a certain time/date, that is.

I'm guessing I need to use some sort of hook functionality and make my own module, true? Or is there any other way of doing this?

1 Answer 1


There's no pre-configured action for making a back-end request like that, so you will need to write some code. It's not going to be terribly hard to accomplish, though. Drupal has a function called drupal_http_request() to hit the external URL. You'll execute that function within a hook_nodeapi() implementation, which runs at various times in the node creation process.

Drupal 6:

 * Implements hook_nodeapi().
function MODULENAME_nodeapi(&$node, $op) {
  // In D6, this hook is executed at various points in the node creation/render process.
  // We only want to run code during the node's "insert" operation.
  if ($op == 'insert') {
    // Only run for RSS nodes.
    if ($node->type == 'rss') {
      // Make a back-end HTTP request to an external resource.
      $url = 'http://my-url.com';
      $response = drupal_http_request($url);
  • And eventually you'll realize this blocks for the response and realize doing this on node insert is a bad idea and should be done in its own process and run cron every minute with a task to do any queue'd Curl requests ... because waiting for timeout of this to complete per insert is silly for an enduser.
    – tenken
    Nov 20, 2013 at 4:49
  • Easy there. One step at a time.
    – Les Lim
    Nov 20, 2013 at 5:10
  • @tenken Thanks to both. I did actually end up using a bit of both answers, and I did take your suggestion and use hook_cron to trigger it on cron
    – Jon Girard
    Nov 20, 2013 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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