class Test1AccessTokenSecret(unittest.TestCase): def setUp(self): try: file = open('API.keys', 'r+') except IOError: print "You need to put key/secret in API.keys" raise except: print "Unexpected error:", sys.exc_info()[0] else: data = json.load(file) file.close() self.plurk = PlurkAPI(data["CONSUMER_KEY"], data["CONSUMER_SECRET"]) def teardown(self): pass def test_invalid_access_key(self): self.plurk.authorize("foor", "bar") r = self.plurk.callAPI('/APP/Profile/getOwnProfile') self.assertIsNone(r) err = self.plurk.error() self.assertEqual(err['code'], "400") self.assertEqual(err['reason'], "BAD REQUEST") self.assertEqual(err['content']['error_text'], "40106:invalid access token")
def getFriendsPlurk(oauth_token, oauth_token_secret, body): from plurk_oauth.PlurkAPI import PlurkAPI #body = urllib.urlencode(body) plurk = PlurkAPI(settings.PLURK_APP_KEY, settings.PLURK_APP_SECRET) plurk.authorize(oauth_token, oauth_token_secret) dd = plurk.callAPI('/APP/FriendsFans/getFriendsByOffset', body) return dd
def plurk_authorize( ): plurk = PlurkAPI("GZpz46uhKUJv", "EWoX6KK9laSEOhtWCJt8n6xZUmvxrliq") plurk.authorize("UNtfaxzZFPI2", "BXP7E9V8GVrHFWJaIDCiZ2ArXKF0xrB8") return plurk
from sys import argv from plurk_oauth.PlurkAPI import PlurkAPI import json import socket plurk = PlurkAPI("TmJ2fUfRcy3X", "kuBsGZH8qBw34h9uytZgNWFC37PkYv66") plurk.authorize("fqG3DURTDfvA", "EcpTJdGsxHEaCx4TxIMlKR1tksPEuf09") script, filename = argv infile = open(filename, "r") filename_prefix = filename.split("/")[-1] total_length = len(infile.read().split("\n")) infile.close() infile = open(filename, "r") errorfile = open("error/%s.error.txt" % (filename_prefix), "w") outf = open("result/%s.user_table.txt" % (filename_prefix), "w") #print >> outfile, (string[0] + "\tgender") i = 0 for l in infile: tmp = l.strip().split("\t") userid = tmp[0] try: temp = plurk.callAPI("/APP/Profile/getPublicProfile", {"user_id": userid}) except: continue
from sys import argv from plurk_oauth.PlurkAPI import PlurkAPI import json import socket plurk = PlurkAPI("TmJ2fUfRcy3X", "kuBsGZH8qBw34h9uytZgNWFC37PkYv66") plurk.authorize("fqG3DURTDfvA", "EcpTJdGsxHEaCx4TxIMlKR1tksPEuf09") script, filename= argv infile = open(filename, "r") filename_prefix= filename.split("/")[-1] total_length = len( infile.read().split("\n") ) infile.close() infile = open(filename, "r") errorfile = open("error/%s.error.txt" %( filename_prefix ) , "w") outf = open("result/%s.user_table.txt" %( filename_prefix ), "w") #print >> outfile, (string[0] + "\tgender") i= 0 for l in infile: tmp = l.strip().split("\t") userid = tmp[0] try: