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.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 714692-9_modify_url.patch | 2.92 KB | alex_b |
| #8 | 714692-8_modify_url.patch | 762 bytes | alex_b |
| #7 | 714692-7_modify_url.patch | 2.92 KB | alex_b |
| #5 | 714692-5_modify_url.patch | 2.92 KB | alex_b |
| #4 | 714692-4_modify_url.patch | 2.92 KB | alex_b |
Comments
Comment #1
alex_b commentedThe 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.
Comment #2
chandrabhan commentedHow do I do that? And where do I use the extended class?
Comment #3
alex_b commentedPlease refer to documentation and code to learn how to write a plugin (=extend one of the plugin classes): http://drupal.org/node/622696
Comment #4
alex_b commentedI'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
Comment #5
alex_b commentedIgnore patches in #4.
Comment #6
alex_b commented"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...
Comment #7
alex_b commentedReroll after recent commits.
Comment #8
alex_b commentedI've committed the modification to FeedsConfigurable class (#4 B) as it is a good think either way.
Rerolled patch to reflect changes.
Comment #9
alex_b commentedCommit from #8 breaks test I had to roll back : (.
Rerolling... this patch should apply, but configDefaultsMerged() can cause infinite loops.
Comment #10
kenorb commentedClosed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.