-
Notifications
You must be signed in to change notification settings - Fork 0
/
fb.py
78 lines (56 loc) · 1.96 KB
/
fb.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
import fbconsole
import pickle
#getting authorization
def login():
fbconsole.AUTH_SCOPE = ['publish_stream', 'read_stream', 'status_update']
fbconsole.authenticate()
#setting a status update
def update_status(update):
status = fbconsole.post('/me/feed', {'message':update})
#print status
#last status update id
#status = status[10:-2]
#print type(status)
#last 5 posts
def get_posts():
last5_data = fbconsole.fql("SELECT status_id, message from status WHERE uid = me() LIMIT 5")
print last5_data
last5_status_id = []
last5_status_message = []
for x in range(0,5):
last5_status_id.append(str(last5_data[0]["status_id"])[:-1])
last5_status_message.append(last5_data[0]["message"])
return last5_status_message
#getting the comments, given the status id
def get_comments(post_id):
comment_data = fbconsole.fql("SELECT text FROM comment WHERE post_id = %s" %(post_id))
no_of_comments = len(comment_data)
comments = []
for y in range(0, no_of_comments - 1):
comments.append(comment_data[y]['text'])
return comments
#getting the comments, given the status id
def get_comments(post_id):
comment_data = fbconsole.fql("SELECT text FROM comment WHERE post_id = %s" %(post_id))
no_of_comments = len(comment_data)
comments = []
for y in range(0, no_of_comments - 1):
comments.append(comment_data[y]['text'])
return comments
def get_name(id):
userid_data = fbconsole.fql("SELECT name FROM profile WHERE id = %s" %(id))
print userid_data[0]["name"]
def get_comments_poster(post_id):
comment_data = fbconsole.fql("SELECT fromid FROM comment WHERE post_id = %s" %(post_id))
no_of_comments = len(comment_data)
posters = []
for z in range(0, no_of_comments):
posters.append(get_name(str(comment_data[z]['fromid'])))
return posters
#getting the username from the uid
#username = fbconsole.fql("SELECT name FROM profile WHERE id = 100001853351818")
#print username
#print type(username)
#pickle.dump(data, open("newdata.p", "wb"))
login()
print get_posts()