Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'd like to propose adding a hook_twitter_fetch_user_timeline() that executes just prior to retrieving recent tweets from Twitter and adding them to the Drupal database. Among other things, this could support a custom-coded module that satisfies a feature request which has come up repeatedly to be able to remove deleted tweets from the Drupal site if they have been deleted from Drupal.com:
Comment | File | Size | Author |
---|---|---|---|
#12 | twitter-n1943440-12-6.x-5.x.patch | 2.87 KB | DamienMcKenna |
#11 | twitter-n1943440-11-7.x-5.x.patch | 2.87 KB | DamienMcKenna |
#9 | twitter-n1943440-9-7.x-6.x.patch | 2.83 KB | DamienMcKenna |
Comments
Comment #1
Sheldon Rampton CreditAttribution: Sheldon Rampton commentedHere's a patch that adds the hook.
Comment #2
Sheldon Rampton CreditAttribution: Sheldon Rampton commentedI've created a sandbox "Twitter delete" module that illustrates how this hook can be used to support deletion of a user's already-archived tweets before fetching the user timeline from Twitter:
http://drupal.org/sandbox/sheldon/1943460
I think my sandbox module would satisfy most of the real-world use cases where people want their Drupal site to stop displaying tweets that have been removed from Twitter. It accomplishes this by simply deleting a user's entire history of tweets before fetching the timeline. This might be a problem for websites that are using the Twitter module to collect a full history of a user's tweets and archive them on Drupal.org, but on the website where I'm using the Twitter module, this isn't an issue. We're simply using the Twitter module as a mechanism for caching a list of recent tweets so my website doesn't have to keep hitting Twitter's API (and running up against the limits of its rate limiter) every time it displays a Twitter block on a page. For reading older tweets, we just give the user a link to Twitter.
My website is the NYSenate.gov (the official website of the New York State Senate), and we need the ability to remove deleted tweets because Senators want to feel confident that if they remove a tweet from Twitter, it will also be promptly removed from NYSenate.gov. Without that confidence, they will not not feel comfortable adding their Twitter blocks to our website. There have been instances where public officials have accidentally posted erroneous information on Twitter, and they want to know that if they make that sort of mistake, they can fix it promptly themselves.
In one of the messages explaining the reasoning for making a "won't fix" decision to past requests for a feature that would support removing deleted tweets, user juampy suggested that it would be "Better to delete it manually or wait until it is automatically deleted after a certain amount of time configured at the module settings page." This suggestion is not a solution for the senators who use NYSenate.gov. We have 64 New York State Senators whose offices all post content to our website, and it would not be practical to create a system through which the staffs working in 64 different offices all have the ability to manually delete individual tweets. It is also not realistic to expect that a senator who wants a tweet removed manually will be willing to wait an hour or several hours, or possibly days, before a request to manually remove a tweet can be relayed to our technical support team and acted upon.
I'm posting this explanation so the Twitter module's maintainers can see how my "Twitter delete" module fills a real need and why hook_twitter_fetch_user_timeline() is therefore useful. It also provides a mechanism by which someone could create a more robust Twitter delete module that zaps recent deleted tweets without deleting older history.
Comment #2.0
Sheldon Rampton CreditAttribution: Sheldon Rampton commentedfix typo
Comment #3
xurizaemonHappy to consider addition of this if re-rolled for 7.x-5.x.
Comment #4
DamienMcKennaComment #6
DamienMcKennaRerolled.
Comment #9
DamienMcKennaThis extends the idea so that there's now hook_twitter_prefetch_timeline(), hook_twitter_statuses_alter() and hook_twitter_insert_statuses().
Comment #10
DamienMcKennaComment #11
DamienMcKennaPorted to 7.x-5.x.
Comment #12
DamienMcKennaPorted to 6.x-5.x.
Comment #14
DamienMcKennaCommitted.