-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathKred.py
More file actions
58 lines (51 loc) · 1.82 KB
/
Kred.py
File metadata and controls
58 lines (51 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""
Date: 18 February 2012
Description:provides an easy to use interface for communicating with the peoplebrowsr API system.
as of the date of publication of this library, the kred API includes methods of kredscore and kred
kred method parameters in addtion to app_id and app_key
source*
term*
kredscore method parameters in addtion to app_id and app_key
source*
term*
*denotes required parameters
"""
class Kred:
def __init__(self, app_id, app_key):
self.app_id = app_id
self.app_key = app_key
self.url = "http://api.kred.ly"
def Kred(self, source, term, influence = "", influenceCommunities = "", name = "", outreach = "", outreachCommunities = ""):
url = self.url + '/kred'
query = "app_id=" + self.app_id
query = query + "&app_key=" + self.app_key
if influence != "":
query = query + "&influence=" + influence
if influenceCommunities != "":
query = query + "&influence_communities=" + influenceCommunities
if name != "":
query = query + "&name=" + name
if outreach != "":
query = query + "&outreach=" + outreach
if outreachCommunities != "":
query = query + "&outreach_communities=" + outreachCommunities
query = query + "&source=" + source
query = query + "&term=" + term
return self.GET(url, query)
def Kredscore(self, source, term, influence = "", name = "", outreach = ""):
url = self.url + '/kredscore'
query = "app_id=" + self.app_id
query = query + "&app_key=" + self.app_key
if influence != "":
query = query + "&influence=" + influence
if name != "":
query = query + "&name=" + name
if outreach != "":
query = query + "&outreach=" + outreach
query = query + "&source=" + source
query = query + "&term=" + term
return self.GET(url, query)
def GET(self, url, query):
import urllib2
response = urllib2.urlopen( url + "?" + query ).read()
return response