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.
Used this module a few times now and found it very helpful, so thanks.
I'd like to not display any tweets that begin with '@', as these are usually meaningless when displayed out of context on my site. Is there a simple way to achieve this?
Comment | File | Size | Author |
---|---|---|---|
#12 | exclude_replies_and_retweets.patch | 4.09 KB | wouters_f |
#8 | twitter_pull-1225338-8.patch | 4.91 KB | gapple |
Comments
Comment #1
irakli CreditAttribution: irakli commentedLet me ask a different question (I promise, there's a point in it :)): what is the criteria for the stream of tweets that you are trying to display now?
Comment #2
gappleThis seems like the same thing I'm looking for. I have a personal site and want to pull in my twitter stream, but don't want my @reply messages to show up. The Twitter JavaScript widgets don't do this, but the web interface filters them out if you're not following the recipient as well as the sender.
I used my own tpl, so it was easy enough to filter the tweets there, but then sometimes the stream will be short tweets.
Comment #3
gappleLooking through the API documentation,
statuses/user_timeline
supports filtering replies via theexclude_replies
parameter, however it applies the filter after the count and so filtered tweets subtract from the total returned. I was unable to find a corresponding parameter for lists or the search API.https://dev.twitter.com/docs/api/1/get/statuses/user_timeline
Comment #4
alexmartin CreditAttribution: alexmartin commentedThanks for the replies. I've had a play with this and can indeed filter out the "@relipes", but as mentioned by gapple, these get subtracted from the count, meaning I may end up with few or no tweets. I'm not very good with php, but here's a simplified version of my tpl code.
Could I instead pull back more tweets (e.g. 20 tweets), then limit the amount of tweets that get printed from the 20 after the filter is applied? Not sure how I'd code this though? It could still fail if there was a very high number of @replies, but as I only want to display 5 tweets, I'm sure that out of the 20, 5 wouldn't be @replies.
Comment #5
gappleI ended up doing exactly that, grabbing 10 tweets and having the tpl stop after printing 5 of them.
Comment #6
alexmartin CreditAttribution: alexmartin commentedthat works brilliantly gapple. Many thanks for your help on this.
Comment #7
gappleI think this is worth keeping open for a proper solution that doesn't require TPL changes.
Comment #8
gappleHere's a simple patch that allows globally filtering replies in user feeds by using a variable. I think it should ultimately be possible to specify per-feed though.
I also added an option for retweets, since it was simple.
Comment #9
davidneedhamWow, this is a tinsy bit old, isn't it? It's no wonder this patch doesn't work anymore. I'll update for 7.x and see if I can reroll this one.
Comment #10
davidneedhamEh, consider this blocked until #1781024: Make the Twitter Pull module work when Twitter turns off the version 1 API due to uncertainty of this project.
Comment #11
bnash2501 CreditAttribution: bnash2501 commentedIf anyone is interested, this can also be solved via applying http://drupal.org/node/1081658 and implementing hook_twitter_pull_tweets_alter and doing a simple regex/substr check on the $tweet->text. Granted, not as elegant as having a nice option available directly from twitter_pull, but may work for some.
Comment #12
wouters_f CreditAttribution: wouters_f commentedI have made this in to a patch.
You can nicely filter retweets/answers out of the results by adding them as a parameter.
See the attached patch.
Comment #13
cdenneen CreditAttribution: cdenneen commented@drupal_sensei
I've extended upon your patch to fix this issue with 7.x-2.x-dev that fixed issues where using NULL values
http://drupal.org/node/1977950
Comment #14
RaulMuroc CreditAttribution: RaulMuroc commentedIT stills catches the repiles.
For example
I tweet " Hei i love #football"
Then reply:
"Me too" <-- this is not catched (NICE!)
Then reply:
"I also love #football" <-- It catches it but i think should not because anyway it has the hashtag it is a Reply!
But somehow when it caches the hashtag just ignores if it is a reply.
Comment #15
RaulMuroc CreditAttribution: RaulMuroc commentedComment #16
RaulMuroc CreditAttribution: RaulMuroc commenteddefinetelty doesn't work. Retweets are still coutned and shown as RE @bla bla [text]
Comment #17
gapple@RaulMuroc If you send the API request manually with the parameter to exclude replies, do you get the correct response?
Unless this module is sending an incorrect request, it's all up to the Twitter API to filter responses properly.
The raw API response may also have additional information that can help you determine why a tweet may not have been filtered, or that it really is an issue with the API.
Comment #18
gappleIt looks like this issue was addressed in #1977950: Enable/Disable Re-Tweets and Replies in Twitter Block Box, so I'll close this as a duplicate