def test_scores(self): #Valid Test 1 username api = Klout(self.KEY) data = api.identity('marcelcaraciolo', 'twitter') user_id = data['id'] data = api.score(user_id) self.assert_(data['score'] < 100.0 and data['score'] > 0.0)
def test_influences(self): #Valid Test 1 username api = Klout(self.KEY) data = api.identity('marcelcaraciolo', 'twitter') user_id = data['id'] data = api.influences(user_id) self.assert_('myInfluencers' in data) self.assert_('myInfluencees' in data)
def test_topics(self): #Valid Test 1 username api = Klout(self.KEY) data = api.identity('marcelcaraciolo', 'twitter') user_id = data['id'] data = api.topics(user_id) for topic in data: for key in topic.keys(): self.assert_(key in ['imageUrl','slug','displayName', 'id', 'name'])
def test_topics(self): #Valid Test 1 username api = Klout(self.KEY) data = api.identity('marcelcaraciolo', 'twitter') user_id = data['id'] data = api.topics(user_id) for topic in data: for key in topic.keys(): self.assert_( key in ['imageUrl', 'slug', 'displayName', 'id', 'name'])
class GetKlout(object): def __init__(self, ): self.api = Klout('your APY KEY') def get_klout(self, user_twitter): data = self.api.identity(str(user_twitter), 'tw') print data user_id = data['id'] score = self.api.score(user_id) return score['score']
#!/usr/bin/python # Twitter ID to weighted influencers # Minor tweak import sys from MaltegoTransform import * from pyklout import Klout api = Klout("YOUR API KEY") me = MaltegoTransform(); me.debug("Starting Transform"); #Debug Info name = str(sys.argv[1]) data = api.identity(name,'twitter') user_id = data['id'] # fails hard if you feed it a name that doesn't have a Klout account # really must find Python equivalent of Try::Tiny for this problem. list = api.influences(user_id) for inf in list['myInfluencers']: name = str(inf['entity']['payload']['nick']); score = str(int(inf['entity']['payload']['score']['score'])); NewEnt = me.addEntity("AffiliationTwitter",name); NewEnt.setWeight(score); NewEnt.addAdditionalFields("affiliation.uid","UID","",name); nurl = "http://twitter.com/" + name; NewEnt.addAdditionalFields("affiliation.profile-url","Profile URL","",nurl); NewEnt.addAdditionalFields("twitter.screen-name","Screen Name","",name); me.returnOutput();
def test_identity(self): api = Klout(self.KEY) data = api.identity('marcelcaraciolo', 'twitter') self.assert_('id' in data) self.assert_('network' in data)
#!C:\Python27 from pyklout import Klout api = Klout('acbxt9d2p52vmgvv2u38nrba') username = raw_input('Twitter username: '******'twitter') except Exception, e: print 'Can\'t find the user %s:\n%s' % (username,e) exit() user_id = user['id'] #User score try: score = api.score(user_id) except Exception, e: print 'Can\'t get the score of %s:\n%s' % (username,e) exit() print 'User score: %f' % (score['score']) #User influences try: data = api.influences(user_id) except Exception, e: print 'Can\'t get influencers of %s:\n%s' % (username,e) exit() print '\nInfluencers\n' for x in data['myInfluencers']: nick = x['entity']['payload']['nick']
def get_klout_score(username): """ Get klout score based on twitter handle """ api = Klout(settings.API_KLOUT_KEY) data = api.identity(str(username), 'twitter') score = api.score(data['id']) return score['score']
#DESC: Transform Twitter entity into Klout topic URLs import sys import time from MaltegoTransform import * from pyklout import Klout # throttle to 8 calls/sec, should permit Maltego to chew through # long lists of Twitter accounts w/o overrunning API limit time.sleep(.125) # https://klout.com/s/developers/home # register an app, get an API key # wil look something like this api = Klout("xfv9wju86xn4wqsqzexample") name = str(sys.argv[1]) me = MaltegoTransform() data = api.identity(name, 'twitter') list = api.topics(data['id']) for topic in list: name = topic['displayName'] slug = topic['slug'] NewEnt = me.addEntity("maltego.URL", name) NewEnt.addAdditionalFields("url", "URL", "", "http://klout.com/topic/" + slug) me.returnOutput()
#!C:\Python27 from pyklout import Klout api = Klout('acbxt9d2p52vmgvv2u38nrba') username = raw_input('Twitter username: '******'twitter') except Exception, e: print 'Can\'t find the user %s:\n%s' % (username, e) exit() user_id = user['id'] #User score try: score = api.score(user_id) except Exception, e: print 'Can\'t get the score of %s:\n%s' % (username, e) exit() print 'User score: %f' % (score['score']) #User influences try: data = api.influences(user_id) except Exception, e: print 'Can\'t get influencers of %s:\n%s' % (username, e) exit() print '\nInfluencers\n' for x in data['myInfluencers']: nick = x['entity']['payload']['nick']