TerenceMcKennaTwitterBot: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[File:TerenceMcKennaTwitterBot1.png]]
[[File:TerenceMcKennaTwitterBot1.png]]
[[File:terenceMcKennaTwitterBot2.png]]
<br>
The code connects with twitter account, opens the text file, reads all the lines as a list
The code connects with twitter account, opens the text file, reads all the lines as a list
and for each list creates a tweet every 1 minute.
and for each list creates a tweet every 1 minute. Install Tweepy.
 
<source lang="python">
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
import tweepy, time, sys
#enter the corresponding information from your Twitter application:
CONSUMER_KEY = 'y0Wr2HY0I990k9qPFSQdCg'
CONSUMER_SECRET = 'blJLnPrHsJezC2rUVXKi7WzlSJhZIcdhrOCjzSUHLs'
ACCESS_KEY = '2159389034-bth62Bn6He5c85uIdmsPynF5UaHPrlUbEZJOhmK'
ACCESS_SECRET = 'IyE44Bflm7OrdU8yUFqTGv3Dv2TV8fT08ISxnaUQo3r6L'
 
# setup the twitter connection...
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
 
# Here we go...
argfile = str(sys.argv[1])
# open the file
filename=open(argfile,'r')
# read all the lines as a big list
f=filename.readlines()
filename.close()
 
# for every line in the file...
for line in f:
    line = line.strip()
   
    api.update_status(line)
    time.sleep(1*60)#Tweet every 15 minutes
   
 
</source>

Latest revision as of 19:17, 7 December 2013

TerenceMcKennaTwitterBot1.png TerenceMcKennaTwitterBot2.png
The code connects with twitter account, opens the text file, reads all the lines as a list and for each list creates a tweet every 1 minute. Install Tweepy.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import tweepy, time, sys
#enter the corresponding information from your Twitter application:
CONSUMER_KEY = 'y0Wr2HY0I990k9qPFSQdCg'
CONSUMER_SECRET = 'blJLnPrHsJezC2rUVXKi7WzlSJhZIcdhrOCjzSUHLs'
ACCESS_KEY = '2159389034-bth62Bn6He5c85uIdmsPynF5UaHPrlUbEZJOhmK'
ACCESS_SECRET = 'IyE44Bflm7OrdU8yUFqTGv3Dv2TV8fT08ISxnaUQo3r6L'

# setup the twitter connection...
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)

# Here we go...
argfile = str(sys.argv[1])
# open the file
filename=open(argfile,'r')
# read all the lines as a big list
f=filename.readlines()
filename.close()

# for every line in the file...
for line in f:
    line = line.strip()
    
    api.update_status(line)
    time.sleep(1*60)#Tweet every 15 minutes