3

The feeds module does fine importing a source file (CSV, in my case) from an external URL. However, I'm trying to schedule Feeds to pull in a report every X days. I need Feeds to fetch at a dynamic URL, say:
www.example.com/report/%start-date%/%end-date%

I'm guessing this would use the Token module, but aside from that I'm not sure what to do.

1

As I know Feeds doesn't have something like that, its maybe a feature that you can propose on they issue list.

A workaround its to create a small module that will work as a proxy for your dynamic address.

You will have something like that :

<?php

function proxy_menu() {
  $items = array();
  $items['proxy-url'] = array(
    'title' => 'Proxy for danymic url',
    'page callback' => 'proxy_get_contents',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK
  );
  return  $items;
}

function proxy_get_contents() {
  $url = 'http://www.example.com/report/%start-date%/%end-date%';
  $request = drupal_http_request($url);
  if ($request->code == 301 || $request->code == 304) {
    return $request->data;
  }
}
  • What a nice thinking @yvan. The only downside I can think about is the load. feeds requires its own site's page and that page has to be booted separately to fetch the actual URL. May be a custom fetching mechanism can do the trick anyway. – AyeshK Sep 28 '12 at 10:25
0

You can extend the FeedsHTTPFetcher class and register your plugin with hook_feeds_plugins(). Then override the fetch method to handle your dynamic URL that's stored in $source_config['source'].

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.