-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTesting Graph API.py
More file actions
71 lines (38 loc) · 1.52 KB
/
Copy pathTesting Graph API.py
File metadata and controls
71 lines (38 loc) · 1.52 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
59
60
61
62
63
64
65
66
67
68
69
70
# coding: utf-8
# In[19]:
from facepy import GraphAPI
# Initialize the Graph API with a valid access token (optional,
# but will allow you to do all sorts of fun stuff).
graph = GraphAPI("EAACEQkPzZBEQBAOaAaKX6JZCsBx3yLJjnXtXR7ZCZAuggxTTAIgXVCutZBEfZBW0ntnIOwHZAtDAZB0rn2eovxlRGeaEkmF50xfxBEzERfRyIamhau2Uv7INgoULMsycZCNTxY3sENe8eDBUVslOTsZBvbWOI6xXuTAi0mTiKalYGQPEf6maP7FUe1Pt6SrdiNHZCGTCIjUbt64c3jeVDkZCxoA3")
# Get my latest posts
posts = graph.get('me/posts')
# In[31]:
posts['paging']['next']
# In[32]:
import requests
# In[63]:
post_limit = 100
x = requests.get(f"https://graph.facebook.com/v2.11/112757542843617/posts?access_token=EAACEQkPzZBEQBAOaAaKX6JZCsBx3yLJjnXtXR7ZCZAuggxTTAIgXVCutZBEfZBW0ntnIOwHZAtDAZB0rn2eovxlRGeaEkmF50xfxBEzERfRyIamhau2Uv7INgoULMsycZCNTxY3sENe8eDBUVslOTsZBvbWOI6xXuTAi0mTiKalYGQPEf6maP7FUe1Pt6SrdiNHZCGTCIjUbt64c3jeVDkZCxoA3&limit={post_limit}&__paging_token=enc_AdCvmOVOK2CWOcoyZBwqxTAOvbSO8cUwCVzWn0YZAlZBjOOFBbbBwYqAAL9VKBa26NctBvgQ9kaJM8bd93bvVoZA71OQN7kbDJKWazLiJbzO36ZB3YAZDZD").json()
# In[98]:
posts = []
months = {
9:"September",
10:"October",
11:"November",
12:"December"
}
for n in range(len(x['data'])):
try:
message = x['data'][n]['message']
day = n%30 + 1
month = n//30 + 9
year = 2017
date = f"{day:02d}/{month:02d}/{year}"
posts.append([message,day,month,year,date])
except:
pass
# In[99]:
import pandas as pd
df = pd.DataFrame(posts,columns=["message","day","month","year","date"])
# In[100]:
df