-
Notifications
You must be signed in to change notification settings - Fork 33
/
sample.py
133 lines (94 loc) · 2.96 KB
/
sample.py
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
"""This module contains an example on using every function in loklak.py and print the result in the console."""
import tempfile
from loklak import Loklak
from pprint import pprint
# Create a loklak object
l = Loklak()
### API Usage
#######################################
# Usage and Testings #
#######################################
# Loklak settings API
settings = l.settings()
pprint(settings)
# Loklak Status API
status = l.status()
pprint(status)
# Loklak Hello API
hello = l.hello()
pprint(hello)
# Loklak Susi API
susi = l.susi('Hi I am Sudheesh')
pprint(susi)
# Loklak Peers API
peers = l.peers()
pprint(peers)
# Loklak Geocode API
#Single place :
geocode = l.geocode(['Barcelona'])
pprint(geocode)
# Multiple place names :
geocode = l.geocode(['New York', 'Singapore'])
pprint(geocode)
# Loklak Geographic Map API
png_data = l.get_map(17.582729, 79.118320, 512, 512, 12, 'Hello')
path = tempfile.mkstemp(suffix=".png")[1]
open(path, 'wb').write(png_data)
#######################################
# Users API
# User Query
user = l.user('sudheesh001')
pprint(user)
# User Query with followers and following list
user = l.user('sudheesh001', '1000', '1000')
pprint(user)
# User Query with followers only
user = l.user('sudheesh001', '1000')
pprint(user)
# User Query with following only
user = l.user('sudheesh001', None, '1000')
pprint(user)
user = l.user('')
pprint(user)
#######################################
# Search API Usage
### Aggregations
searchAggregation1 = l.aggregations('sudheesh001',None,None,['mentions','hashtags'],10)
pprint(searchAggregation1)
searchAggregation2 = l.aggregations('sudheesh001','2015-01-10','2015-10-21',['mentions','hashtags'],10)
pprint(searchAggregation2)
searchAggregation3 = l.aggregations('sudheesh001',None,'2015-10-21',['mentions','hashtags'],10)
pprint(searchAggregation3)
searchAggregation4 = l.aggregations('sudheesh001','2015-10-21',None,['mentions','hashtags'],10)
pprint(searchAggregation4)
searchAggregation5 = l.aggregations('sudheesh001',None,None,['mentions','hashtags'])
pprint(searchAggregation5)
### Search
search1 = l.search('sudheesh001')
pprint(search1)
search2 = l.search('sudheesh001','2015-01-10')
pprint(search2)
search3 = l.search('sudheesh001', None, '2015-01-10')
pprint(search3)
search4 = l.search('sudheesh001', '2015-01-10', None)
pprint(search4)
search5 = l.search('sudheesh001', '2015-01-10', '2015-01-21')
pprint(search5)
search6 = l.search('sudheesh001', '2015-01-10', '2015-01-21','sudheesh001')
pprint(search6)
search7 = l.search('gunvirranu', None, None, None, 6)
pprint(search7)
###loklak Suggestion API
suggestion1 = l.suggest()
pprint(suggestion1)
suggestion2 = l.suggest(count=20, order='desc')
pprint(suggestion2)
suggestion3 = l.suggest(count=10, order='asc')
pprint(suggestion3)
### account
account1 = l.account('name')
pprint(account1)
account2 = l.account('name','update','type')
pprint(account2)
# Try call function without name
account3 = l.account(action='update', data='type')