Skip to content

Commit

Permalink
use API keys from file
Browse files Browse the repository at this point in the history
  • Loading branch information
cl_sung committed May 23, 2011
1 parent 60ec597 commit c303803
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions bin/get_own_profile.py
Expand Up @@ -2,21 +2,30 @@
sys.path.append('plurk-oauth/')
from PlurkAPI import PlurkAPI
import getopt
import json

def usage():
print '''Help Information:
-h: Show help information
'''

CONSUMER_KEY = 'KEY'
CONSUMER_SECRET = 'SECRET'

if __name__ == '__main__':
try:
opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="])
except getopt.GetoptError, err:
print str(err) # will print something like "option -a not recognized"
usage()
sys.exit(2)
plurk = PlurkAPI(CONSUMER_KEY, CONSUMER_SECRET)
file = open('API.keys', 'r+')
data = json.load(file)
plurk = PlurkAPI(data["CONSUMER_KEY"], data["CONSUMER_SECRET"])
if data.get('ACCESS_TOKEN'):
plurk.authorize(data["ACCESS_TOKEN"],data["ACCESS_TOKEN_SECRET"])
else:
plurk.authorize()
data["ACCESS_TOKEN"] = plurk._oauth.oauth_token['oauth_token']
data["ACCESS_TOKEN_SECRET"] = plurk._oauth.oauth_token['oauth_token_secret']
json.dump(data,file)

print plurk.callAPI('/APP/Profile/getOwnProfile')

0 comments on commit c303803

Please sign in to comment.