I was wondering if it is possible to "quote a tweet" through direct messages using TweePy. I know this can be done regularly in the Twitter app using the share feature but I was wondering if this could also be possible through Python.
Tweepy recommends that you send the URL of the tweet in a direct-message. https://github.com/tweepy/tweepy/issues/859
The URL will generate a formatted preview in the recipients inbox.
Related
I'm quite a novice, so please excuse my ignorance.
I've created a developer account on my personal Twitter account and my end goal is to have another account occasionally tweet something. I'm using tweepy and have successfully managed to tweet something, albeit from my account.
Twitter developer accounts can get their API key and secret, as well as an Access key and secret. What I'm trying to figure out is how to get my bot account's keys to have it tweet instead of my account.
After reading countless pages online as well as the docs, there seems to be a way to get auth another user through three-legged auth and pin-based auth, which seems like the correct route to my goal.
However, I have no idea where to go from here. The three-legged auth page asks for various required fields, of which I have no idea what to fill with (Callback URLs and Website URL). Moreover, the docs describe the process as one that needs to be initiated by the dev account, and I have no idea how to initiate that process at all.
Any help or guidance on what to do? My tweepy script is fully finished and just needs to be hooked up to the Twitter API.
Thanks.
EDIT & SOLUTION (03/18/2021):
Thanks to the comment by Sim leading to the article, I was able to derive a python script using Tweepy to authorize the bot using pin-based auth, found here. I'd give the article a read regardless, but once it starts telling you to create .js and .json files, stop there and use my script. That's what worked for me.
Found a solution that worked for me, I think this is what you need. https://dev.to/stratospher/many-bot-accounts-using-1-twitter-developer-account-17ff
I want to retrieve the text data for a specific twitter account and save it for a ML project about text generation, is this possible using the Twitter API?
Yes. It is possible. Try tweepy. It is a wrapper for Twitter API.
I'm working on an automatic text to speach generator using tweep and gTTS.
And what I'd like to is whenever a user tags my bot, my bot will reply with a generated TTS response of their tweet.
Example if Malcolm tweets "#bot Banana Bread" well the bot will reply to that tweet with a mp4 file of a voice saying "banana bread"
I think I could pull of the TTS generation with gTTS and some messing around.
However I don't know how I could automatically get the tweet Id and so the tweets text when I'm tagged.
The only method I see is to constantly refresh a
example = tweepy.Cursor(api.search, q='#bot').items(1)
and then
for tweet in example:
print tweet.text, tweet.id_str
and then store the id so that it only gets the latest posts and doesn't reply to the same tweet twice.
But this seems like a bit much, and I'm wondering if there's any faster/easier/more efficient way of doing this?
Your method is good : store tweet IDs you answered to, and check them before a new reply. With time, it can be a lot of IDs so you have to handle delete of very old ones.
Another way is to use the Twitter Account Activity API : via a webhook (an URL of your personnal web server), you can get mention events, then simply reply directly.
If i understand the official documentation, 1 free webhook is available with premium API.
Here is documentation :
https://developer.twitter.com/en/use-cases/engage#chatbots-and-automation
https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/overview
I am trying to fetch all tweets using tweepy. I cannot find a document to show how to fetch all tweets rather than filter data using some keywords.
I tried "stream.filter()" without parameters, but it still does not work.
Could anyone give some help?
Thanks.
Is there any better way to get tweets from twitter then crawling twitter.com and mutating URLs?
If there is, how can I get latest tweets with current hash-tag?
Thank you!
Did you try Twitter REST API? Particulary, you can use search tweets endpoint. There are some limitations though, enforced by Twitter.
You can use one of many available python libraries.
For example, some sample code for tweepy can be found here.