Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
 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'])
Ejemplo n.º 6
0
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']
Ejemplo n.º 7
0
 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'])
Ejemplo n.º 8
0
    def test_scores(self):
        #Valid Test 1 username
        api = Klout(self.KEY)
        data = api.score(['rafaelcaricio'])
        self.assertEquals(data[0][0], 'rafaelcaricio')
        self.assert_(data[0][1] < 100.0  and data[0][1] > 0.0)

        #Valid Test 5 usernames
        api = Klout(self.KEY)
        data = api.score(['rafaelcaricio', 'marcelcaraciolo', 'atepassar_', 'caocurseiro', 'google'])
        for (key, value) in data:
            self.assert_(key in ['rafaelcaricio', 'marcelcaraciolo', 'atepassar_', 'caocurseiro', 'google'])
            self.assert_(value <= 100.0  and value >= 0.0)

        #Valid Test Invalid Username in Twitter
        api = Klout(self.KEY)
        self.assertRaises(KloutError, api.score, ['ahahahahah'])

        #Valid Test No Data
        api = Klout(self.KEY)
        self.assertRaises(KloutError, api.score, [])

        #Valid Test More than 5
        api = Klout(self.KEY)
        usernames = ['rafaelcaricio', 'marcelcaraciolo', 'atepassar_', 'caocurseiro', 'google', 'timoreilly','googleapps']
        data = api.score(usernames)
        self.assertEquals(len(data),5)
        for (key, value) in data:
            self.assert_(key in ['rafaelcaricio', 'marcelcaraciolo', 'atepassar_', 'caocurseiro', 'google'])
            self.assert_(value <= 100.0  and value >= 0.0)
Ejemplo n.º 9
0
    def test_users_topics(self):
        #Valid Test 1 username
        api = Klout(self.KEY)
        data = api.users_topics(['marcelcaraciolo'])
        self.assertEquals(len(data),1)
        self.assertEquals(data[0].keys(),['marcelcaraciolo'])

        #Valid Test 5 usernames
        api = Klout(self.KEY)
        data = api.users_topics(['rafaelcaricio', 'marcelcaraciolo', 'atepassar_', 'caocurseiro', 'srlm'])
        self.assert_(len(data) <= 5)
        for user in data:
            for key in user.keys():
                self.assert_(key in ['rafaelcaricio', 'marcelcaraciolo', 'atepassar_', 'caocurseiro', 'srlm'])

        #Valid Test Invalid Username in Twitter
        api = Klout(self.KEY)
        self.assertRaises(KloutError, api.users_topics, ['ahahahahah'])

        #Valid Test No Data
        api = Klout(self.KEY)
        self.assertRaises(KloutError, api.users_topics, [])

        #Valid Test More than 5
        api = Klout(self.KEY)
        usernames = ['rafaelcaricio', 'marcelcaraciolo', 'atepassar_', 'caocurseiro', 'google', 'timoreilly','googleapps']
        data = api.users_topics(usernames)
        self.assert_(len(data) <= 5)
        for user in data:
            for key in user.keys():
                self.assert_(key in ['rafaelcaricio', 'marcelcaraciolo', 'atepassar_', 'caocurseiro', 'google'])
Ejemplo n.º 10
0
    def test_users_show(self):
        #Valid Test 1 username
        api = Klout(self.KEY)
        data = api.users_show(['rafaelcaricio'])
        self.assertEquals(len(data),1)
        self.assertEquals(data[0]['twitter_screen_name'],'rafaelcaricio')
        for user in data:
            for key in user.keys():
                self.assert_(key in ['score', 'twitter_id', 'twitter_screen_name'])

        #Valid Test 5 usernames
        api = Klout(self.KEY)
        data = api.users_show(['rafaelcaricio', 'marcelcaraciolo', 'atepassar_', 'caocurseiro', 'srlm'])
        self.assertEquals(len(data),5)
        for user in data:
            for key in user.keys():
                self.assert_(key in ['score', 'twitter_id', 'twitter_screen_name'])

        #Valid Test Invalid Username in Twitter
        api = Klout(self.KEY)
        self.assertRaises(KloutError, api.users_show, ['ahahahahah'])

        #Valid Test No Data
        api = Klout(self.KEY)
        self.assertRaises(KloutError, api.users_show, [])

        #Valid Test More than 5
        api = Klout(self.KEY)
        usernames = ['rafaelcaricio', 'marcelcaraciolo', 'atepassar_', 'caocurseiro', 'pugpe', 'srlm']
        data = api.users_show(usernames)
        self.assertEquals(len(data),5)
        for user in data:
            for key in user.keys():
                self.assert_(key in ['score', 'twitter_id', 'twitter_screen_name'])
Ejemplo n.º 11
0
 def test_identity(self):
     api = Klout(self.KEY)
     data = api.identity('marcelcaraciolo', 'twitter')
     self.assert_('id' in data)
     self.assert_('network' in data)
Ejemplo n.º 12
0
#!/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()
Ejemplo n.º 13
0
 def test_identity(self):
     api = Klout(self.KEY)
     data = api.identity('marcelcaraciolo', 'twitter')
     self.assert_('id' in data)
     self.assert_('network' in data)
Ejemplo n.º 14
0
#!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']
Ejemplo n.º 15
0
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']
Ejemplo n.º 16
0
#!/usr/bin/python
#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()
Ejemplo n.º 17
0
#!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']
Ejemplo n.º 18
0
 def test_createKloutAPI(self):
     api = Klout(self.KEY)
     self.assertEquals(api._api_key, self.KEY)
Ejemplo n.º 19
0
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']
Ejemplo n.º 20
0
#!/usr/bin/python
#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();
Ejemplo n.º 21
0
 def __init__(self, ):
     self.api = Klout('your APY KEY')
Ejemplo n.º 22
0
#!/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();
Ejemplo n.º 23
0
from MaltegoTransform import *
from pyklout import Klout

args = sys.argv[2].split("#")
names = args[2].split("=")
name = str(names[1])
name = re.sub(" ", "", name)

# 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")

me = MaltegoTransform()

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)