Currently Feeds takes a static URL as part of the configuration. I am looking for a feature where this can be tokenized (with say, [user id]) and a hook to be implemented by admins to provide a list of values for this token BEFORE cron starts fetching the feed. Feed URL should be fetched in a loop if multiple values are provided by the hook.

The business case is to fetch content from social networking sites for a particular user of the system selected based on certain criteria.

Comments

alex_b’s picture

Title: Tokenized feed url » Modify feed url before issueing request
Version: 6.x-1.0-alpha9 » 6.x-1.x-dev

The general case is modifying the feed URL before you use it for download. I've just recently had a similar use case where I wanted to sign the URL using message signing library before using it to issue a request.

I am not sure yet whether a hook for modifying the URL is a good idea. The reason is that a hook won't negotiate which implementer modifies a URL and more likely than not more than one implementer modifying a URL will break it.

For now, I recommend extending FeedsHTTPFetcher and overriding the fetch() method.

chandrabhan’s picture

How do I do that? And where do I use the extended class?

alex_b’s picture

Please refer to documentation and code to learn how to write a plugin (=extend one of the plugin classes): http://drupal.org/node/622696

alex_b’s picture

Title: Modify feed url before issueing request » Modify feed url before issueing request, allow adding to config with form_alter
Status: Active » Needs review
StatusFileSize
new2.92 KB
new2.92 KB

I've been thinking more about this request. If we add an alter hook to the URL (= $source_config) before fetching, chances are we'd like to be able to also add settings to an importer configuration via form_alter. This is currently not possible because any setConfig() or addConfig() on a configurable object will be filtered by the default values declared in defaultConfig().

This patch:

A) adds a hook_feeds_prefetch_alter(&$source_config, $fetcher);
B) modifies FeedsConfigurable so that defaultConfig() is not mandatory anymore. This allows third party modules to add feeds importer settings via form_alter.

For an example on how to use this API, see here: http://pastebin.com/m297509d1

alex_b’s picture

StatusFileSize
new2.92 KB

Ignore patches in #4.

alex_b’s picture

"in configDefaults." needs to be "in configDefaults()."

I am not really sold on hook_feeds_prefetch_alter(). It's very general and thus suggests that we add such a hook invocation to all fetchers, maybe even a corresponding hook invokation to all parsers and processors. I'm considering renaming it to sth more specific that does not raise expectations on what else should be modifyable...

alex_b’s picture

StatusFileSize
new2.92 KB

Reroll after recent commits.

alex_b’s picture

StatusFileSize
new762 bytes

I've committed the modification to FeedsConfigurable class (#4 B) as it is a good think either way.

Rerolled patch to reflect changes.

alex_b’s picture

Status: Needs review » Needs work
StatusFileSize
new2.92 KB

Commit from #8 breaks test I had to roll back : (.

Rerolling... this patch should apply, but configDefaultsMerged() can cause infinite loops.

kenorb’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

Closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.