0

I use Python 2.7.15 and I am trying to create a GUI that will let you tweet with a custom source label ("Twitter for ...") but my current code while accepting the variable for the source label it does not like the status as a variable.

Code:

import tweepy
from Tkinter import *

auth = tweepy.OAuthHandler('lol', 'nice')
auth.set_access_token('try', 'xD')

api = tweepy.API(auth)

def tweet():
    message = messageStorage.get()
    sourceLabel = sourceLabelStorage.get()
    api.update_status(message, source = sourceLabel)

gui = Tk()
gui.title('')

messageStorage = StringVar()
sourceLabelStorage = StringVar()

label0 = Label(gui, text='Enter Tweet').pack()
entry0 = Entry(gui, textvariable=messageStorage).pack()
label1 = Label(gui, text='Enter Source Label').pack()
entry1 = Entry(gui, textvariable=sourceLabelStorage).pack()
button0 = Button(gui, text='Tweet', command=tweet(), bg='#1da1f2').pack(pady=5)

gui.mainloop()

Error:

Traceback (most recent call last):
  File "C:/Users/My Name/Desktop/customSourceLabel_twitter.py", line 24, in <module>
    button0 = Button(gui, text='Tweet', command=tweet(), bg='#1da1f2').pack(pady=5)
  File "C:/Users/My Name/Desktop/customSourceLabel_twitter.py", line 12, in tweet
    api.update_status(message, source = sourceLabel)
  File "C:\Python27\lib\site-packages\tweepy\api.py", line 195, in update_status
    )(post_data=post_data, *args, **kwargs)
  File "C:\Python27\lib\site-packages\tweepy\binder.py", line 250, in _call
    return method.execute()
  File "C:\Python27\lib\site-packages\tweepy\binder.py", line 234, in execute
    raise TweepError(error_msg, resp, api_code=api_error_code)
TweepError: [{u'message': u'Missing required parameter: status.', u'code': 170}]

Thanks in advance

1 Answers1

0

From the Tweepy documentation, it looks as if you must explicitly identify that first parameter as status, like so:

api.update_status(status=message, source=sourceLabel)

EDIT: As @Bryan Oakley points out, there is also another bug in your code--in your call to Button(), the parameter command=tweet shouldn't have parentheses after the function name--but that's separate from and in addition to the error message you've posted.

B. Shefter
  • 877
  • 7
  • 19