wcm tweet update

This is a python script to update twitter that wcmckee.com has been updated.


In [9]:
import tweepy
import sys

In [10]:
opconkey = open('/home/wcmckee/twconkey.txt', 'r')
conkeys = opconkey.read().strip('\n')

opconsec = open('/home/wcmckee/twconsec.txt', 'r')
consecs = opconsec.read().strip('\n')

opacckey = open('/home/wcmckee/twacckey.txt', 'r')
acckeys = opacckey.read().strip('\n')

opaccsec = open('/home/wcmckee/twaccsec.txt', 'r')
accsecs  = opaccsec.read().strip('\n')

In [10]:


In [13]:
#argfile = str(sys.argv[1])
 
#enter the corresponding information from your Twitter application:
#conskey = '1234abcd...'#keep the quotes, replace this with your consumer key
#consec = '1234abcd...'#keep the quotes, replace this with your consumer secret key
#acckey = '1234abcd...'#keep the quotes, replace this with your access token
#accsec = '1234abcd...'#keep the quotes, replace this with your access token secret
auth = tweepy.OAuthHandler(conkeys, consecs)
auth.set_access_token(acckeys, accsecs)
api = tweepy.API(auth)
update = ('this is an update')
api.update_status(update)


---------------------------------------------------------------------------
TweepError                                Traceback (most recent call last)
<ipython-input-13-dcf1505ad7c9> in <module>()
     10 api = tweepy.API(auth)
     11 update = ('this is an update')
---> 12 api.update_status(update)

/usr/local/lib/python2.7/dist-packages/tweepy/api.pyc in update_status(self, media_ids, *args, **kwargs)
    191             allowed_param=['status', 'in_reply_to_status_id', 'lat', 'long', 'source', 'place_id', 'display_coordinates'],
    192             require_auth=True
--> 193         )(post_data=post_data, *args, **kwargs)
    194 
    195     def media_upload(self, filename, *args, **kwargs):

/usr/local/lib/python2.7/dist-packages/tweepy/binder.pyc in _call(*args, **kwargs)
    237             return method
    238         else:
--> 239             return method.execute()
    240 
    241     # Set pagination mode

/usr/local/lib/python2.7/dist-packages/tweepy/binder.pyc in execute(self)
    187                                                 proxies=self.api.proxy)
    188                 except Exception as e:
--> 189                     raise TweepError('Failed to send request: %s' % e)
    190                 rem_calls = resp.headers.get('x-rate-limit-remaining')
    191                 if rem_calls is not None:

TweepError: Failed to send request: data must be a byte string

In [14]:
my_str = "hello world"
bytes = str.encode(my_str)
type(bytes) # insures its bytes
my_decoded_str = str.decode(bytes)
type(my_decoded_str) # insures its string


Out[14]:
unicode

In [ ]: