I have built a script to read my Gmail inbox for a new email, if found store it for posting and mark the email as "read". Everything has been working fine there.
I have since been trying to fuse Tweepy into this to post said stored email to twitter. Except it looks like tweepy doesn't like my variable "part.get_payload()"
api.update_status("Test")
....works fine and posts to twitter
TweetMsg = part.get_payload()
api.update_status(TweetMsg)
....doesnt post anything to twitter
Looking through Tweepy documentation I couldnt find any info on using variables with Status Updates. Any Advice?
Related
I've been trying to create a tweet with an image using Tweepy Client (https://docs.tweepy.org/en/stable/client.html#tweepy.Client.create_tweet) and unfortunately I haven't managed to success. I've tried with older version API but it asks to have elevated access.
Currently I can only send a normal tweet doing the following:
client = tweepy.Client(
bearer_token=self.__bearer_token,
consumer_key=self.__consumer_key,
consumer_secret=self.__consumer_secret,
access_token=self.__access_token,
access_token_secret=self.__access_token_secret
)
client.create_tweet(
text="Here there is my tweet"
)
Thank you very much.
A user in Twitter community web answered this question:
It looks like you have essential access, if so then you can only use API v2 and can’t use v1.1 yet, while the media upload endpoint is not yet available in v2.
Reference:
https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/integrate#media
I have created a twitter bot using the Tweepy API. It works great, it tweets a tweet with a photo attached to it. However, I would like to add "mentions" or "In this photo" #accounts (tags) to the attached image. This is possible on twitter. I have red the Tweepy documentation and searched online, looking for a parameter but I could not find anything. Any suggestion would appriciated!
code snippet:
api = tweepy.API(oauth)
api.update_with_media(filename='screenshot.png', status=masterStatus)
First of all, please do not use update_with_media, as this is a deprecated API. It works for now, but will get no support. The current correct route is the two-step use of media_upload, followed by update_status (you can also add image alt text using create_media_metadata in between those two steps, if you like). The Tweepy 3.9.0 documentation mentions this.
For the main part of the question - the Twitter API itself does not currently support adding people tags to images, so this is also unavailable in Tweepy. If you would like to request this feature in a future version of the Twitter API, you can do so here.
I'm trying to use the Vimeo API with Python, but I'm stuck trying to find video's using keywords.
What I have is this, after successfully registering with Vimeo:
import vimeo
client = vimeo.VimeoClient(
token='my_token',
key='my_key',
secret='my_secret_key'
)
about_me = client.get('/me',params={'fields':'uri,name'})
json.loads(about_me.text)
these return my user credentials. Now I want to use a similar approach to get videos using Query keywords, like on their page. But I cannot get it to work.
So, I want to have a JSON returned with movies based on keywords (like 'interstellar trailer' and not the URI or id of Vimeo).
But for some reason, I can't get the query keyword to work, and from the linked page above, I cannot figure it out how to implement it in my code.
27-02-19: UPDATE: I figured it out, and will update my solution here, soon.
The /me endpoint only returns the user object for the authenticated user.
To get and search for videos, use the /me/videos or /videos endpoint (depending on if you are searching for videos on your own account, or searching for videos from other users public on Vimeo).
This is the script
auth = tweepy.OAuthHandler()
auth.set_access_token()
api = tweepy.API(auth)
for friend in tweepy.Cursor(api.friends, count = 200).items():
print(friend.name.encode('utf-8')
All I'm trying to do is print twitter followers names using tweepy, it prints most out but with some I receive "/xe4 /x9d"
I've tried using different code pages but none seem to work. I'm also using Pydev for Eclipse as an IDE, I left the auth and auth.set blank on purpose, please let me know if this is fixable to display the proper name of the twitter follower
I just got started programming a year ago (on and off) and I am trying to save an attachment to a folder offline from my personal GMAIL account.
I was advised to use :
https://developers.google.com/gmail/api/quickstart/python
I set up the
I authenticated the my account and now am trying to get comfortable with this tool.
There are some initial questions that I have
What is User ID ?
is this my email ( tttt#xxxx.xxxx)
or someone else's email (ppppp#yyyy.yyy)
How do I get a email ID's ?
These questions stem from ...
GET https://www.googleapis.com/gmail/v1/users/userId/messages/messageId/attachments/id
from the page :
https://developers.google.com/gmail/api/v1/reference/users/messages/attachments/get
Again I am just learning from a beginner place..
Thanks
Just use "me" as the userId as it says in the doc.
To get a messageId first you have to search (list) messages, using something like:
resp = gmail.users().messages().list(userId="me", q="has:attachment subject:'foo bar' before:"2014-01-05").execute()
you can then iterate through the 'messages' in that resp and
gmail.users().messages().get(userId="me", id=message['id']).execute()
The Gmail API guides are quite helpful, take a look at them, for example:
https://developers.google.com/gmail/api/guides/filtering