Fairly new to Twython, hope I'm not sounding too dumb here.
Currently I have Twython listening to the Twitter streaming API for tweets from a single user, then triggering a relay to open a door. It's working well, but I've found that it will trigger whenever my target user tweets something (good) AND whenever anyone tweets anything to my target user (not good).
Is there any way to have Twython trigger an action only when a user tweets, and ignore any replies or new tweets that user?
Any help much appreciated - thanks for reading!~
you can check the tweet's user field (in the json you get from your stream listener) and verify that it was tweeted by the desired user.
look here for further details: https://dev.twitter.com/overview/api/users
Related
I'm trying to create a Twitter bot with Python. So my problem is, is there a function that allows me to get the mentions of a tweet, so I can reply to them?
To write a bot who can reply to tweets mentionning it :
You can use the standard statuses/filter API to watch for tweets mentionning your bot.
For this, the standard search operators says that you just have to write "#yourbot" in the query to get tweets mentionning this user.
Then you can use the POST statuses/update to reply, with the in_reply_to_status_id parameter which is the tweet id to reply to.
I been successfully able to use Twitter REST API to do find tweets and retweet them automatically. Now I want to tweet user a Thank You Message, I am using Python and Tweepy for my BOT. I can do live collection of tweets, using Twitter Streaming API, but I can't understand how to use the API to send a thank you message to those who favorite my tweets. I saw both the documentations but couldn't understand and use much from there. I also tried to search for any example but couldn't find any good one for Streaming API.
Can anyone show me how to use it with tweepy to achieve the same. It would be nice if you can show how to use it when someone retweets my tweet or follows me, I want to send them a thank you tweet automatically.
PS: I understand that Twitter doesn't likes much automation. But its all for learning.
i'm having problem with the twitter api. I used this script Script to delete tweets
To delete the tweets form an account. I see that tweepy method (api,user_timeline) at
for status in tweepy.Cursor(api.user_timeline).items():
try:
will not return those tweets that contain media (accessing twitter from the website they don't show up in the timeline but in another tab called 'photos and videos') so they are not deleted. include_entities is not a parameter for this method.
how can i recover these tweets? I thought i could searching with the username as query, but that doesn't work and could be very inefficient.
is there another method on the twitter API or a parameter that's not included with the documentation?
Thanks for all the help!
I found that this is a problem twitter has when erasing massively tweets. Nothing we can do for now!
I'm trying to do a Python program to follow some users based on the hastags they use on their posts. I know about the instagram package for Python, but there are a few things I don't understand about it.
Do I need a token for writing this program? If so, what exacly is a token? And when I run the get-token function it asks me to write the redirect URL, the requested scope, and the "Paste in code in query string after redirect: ", and I have no idea of that is this.
Thank you, JM
You need to understand OAuth 2 in order to appreciate what a token really means. But in essence the redirect URL is the place to where Instagram sends a user who wants to use your app after he approves of it. You will need to host your application. (How to do this?). Also Instagram has a page that helps developers get started here.
Once you are done with the above steps and have the token, you can do something like this,
from instagram.client import InstagramAPI
access_token = "YOUR_ACCESS_TOKEN"
api = InstagramAPI(access_token=access_token)
# Subscribe to all media tagged with 'fox'
api.create_subscription(object='tag', object_id='fox', aspect='media', callback_url='http://example.com/hook/instagram')
I am looking through the Tweepy API and not quite sure how to find the event to register for when a user either send or receives a new tweet. I looked into the Streaming API but it seems like that is only sampling the Twitter fire house and not really meant for looking at one indvidual user. What I am trying to do is have my program update whenever something happens to the user. Essentially what a user would see if they were in their account on the twitter homepage. So my question is: What is the method or event I should be looking for in the Tweepy API to make this happen?
Don't know much about tweepy, but you should really look into Twitter's API Document here, which describes your need directly.
And I took a look at tweepy but don't seem to find it support the userstream series of Twitter API, maybe you have to wrap it yourself :-)
I don't think there is any event based pub-sub exposed by twitter. You just have to do the long polling.
I used the .filter function then filtered for the user I was looking for.