Commit eb1b739be059f7f963317418ebe3ced958cfea92

Authored by suyoun ago
1 parent 2663a7c056
Exists in master

facebook graph version 변경

Showing 1 changed file with 2 additions and 1 deletions Inline Diff

insight/context.py View file @ eb1b739
#!/usr/bin/env python 1 1 #!/usr/bin/env python
# -*- coding: utf-8 -*- 2 2 # -*- coding: utf-8 -*-
import requests 3 3 import requests
import json 4 4 import json
import time 5 5 import time
6 6
7 7
class Context() : 8 8 class Context() :
9 9
token = "" 10 10 token = ""
contents_list = [] 11 11 contents_list = []
orderlist = [529491587137957,858096217617804,1670879929842831,1406069429705944,1531526667169602, 12 12 orderlist = [529491587137957,858096217617804,1670879929842831,1406069429705944,1531526667169602,
504207933048979,813554295420159,265757330288799,270103526524526,1702892339935231, 13 13 504207933048979,813554295420159,265757330288799,270103526524526,1702892339935231,
886456498082470,167968880220563,526019510826052,153258784853075,327293184069664, 14 14 886456498082470,167968880220563,526019510826052,153258784853075,327293184069664,
497899983625735,415438118555115,147088008818887,502626173152828,171144389693855, 15 15 497899983625735,415438118555115,147088008818887,502626173152828,171144389693855,
205240682996725,1440924922793255,119386554923285,500415013370641] 16 16 205240682996725,1440924922793255,119386554923285,500415013370641]
17 17
pagelist = {'529491587137957':'피키캐스트','858096217617804':'피키픽처스','1670879929842831':'피키예능촌', 18 18 pagelist = {'529491587137957':'피키캐스트','858096217617804':'피키픽처스','1670879929842831':'피키예능촌',
'1406069429705944':'피키툰','1531526667169602':'피키키키키','504207933048979':'피키생활백서', 19 19 '1406069429705944':'피키툰','1531526667169602':'피키키키키','504207933048979':'피키생활백서',
'265757330288799':'피키스토리','270103526524526':'곰들의반란','1702892339935231':'궁금청년', 20 20 '265757330288799':'피키스토리','270103526524526':'곰들의반란','1702892339935231':'궁금청년',
'886456498082470':'우주인','167968880220563':'끔켬','526019510826052':'언어유희왕', 21 21 '886456498082470':'우주인','167968880220563':'끔켬','526019510826052':'언어유희왕',
'327293184069664':'연애의모든것','497899983625735':'베스트비디오', 22 22 '327293184069664':'연애의모든것','497899983625735':'베스트비디오',
'415438118555115':'남자기때문에','147088008818887':'도기도기','502626173152828':'여자라면', 23 23 '415438118555115':'남자기때문에','147088008818887':'도기도기','502626173152828':'여자라면',
'171144389693855':'영화공장','813554295420159':'피키무비', 24 24 '171144389693855':'영화공장','813554295420159':'피키무비',
'153258784853075':'플레이','205240682996725':'어머이건봐야돼','1440924922793255':'메운여자', 25 25 '153258784853075':'플레이','205240682996725':'어머이건봐야돼','1440924922793255':'메운여자',
'119386554923285':'당신의뇌를자극할이야기','500415013370641':'그곳에가고싶다'} 26 26 '119386554923285':'당신의뇌를자극할이야기','500415013370641':'그곳에가고싶다'}
27 27
28 28
def __init__(self, token): 29 29 def __init__(self, token):
#print "context" 30 30 #print "context"
self.token = token.getToken() 31 31 self.token = token.getToken()
32 32
def isNext(self,data): 33 33 def isNext(self,data):
if data['data'] == []: 34 34 if data['data'] == []:
return False 35 35 return False
else: 36 36 else:
return True 37 37 return True
38 38
def nextUrl(self,data): 39 39 def nextUrl(self,data):
try: 40 40 try:
return data['paging']['next'] 41 41 return data['paging']['next']
except: 42 42 except:
return "" 43 43 return ""
44 44
def setOrderList(self, list): 45 45 def setOrderList(self, list):
self.orderlist = list 46 46 self.orderlist = list
47 47
def setPageList(self, dic): 48 48 def setPageList(self, dic):
self.pagelist = dic 49 49 self.pagelist = dic
50 50
def getPageList(self): 51 51 def getPageList(self):
return self.pagelist 52 52 return self.pagelist
53 53
def getOrderList(self): 54 54 def getOrderList(self):
return self.orderlist 55 55 return self.orderlist
56 56
57 57
def setContextsFeed(self): 58 58 def setContextsFeed(self):
59 59
self.setContextsFeedAndTimestemp(0) 60 60 self.setContextsFeedAndTimestemp(0)
61 61
def setContextsFeedAll(self): 62 62 def setContextsFeedAll(self):
63 63
signed_max_int = 0x7fffffff - 1 64 64 signed_max_int = 0x7fffffff - 1
self.setContextsFeedAndTimestemp(signed_max_int) 65 65 self.setContextsFeedAndTimestemp(signed_max_int)
66 66
def setContextsFeedAndTimestemp(self,ts): 67 67 def setContextsFeedAndTimestemp(self,ts):
68 68
time_now = int(time.time()) 69 69 time_now = int(time.time())
70 70
return_val = [] 71 71 return_val = []
for list in self.orderlist: 72 72 for list in self.orderlist:
time.sleep(1) 73 73 time.sleep(1)
url = 'https://graph.facebook.com/v2.5/%d/feed?'%list 74 74 url = 'https://graph.facebook.com/v2.6/%d/feed?'%list
75 print url + self.token
txt = requests.get(url + self.token).text 75 76 txt = requests.get(url + self.token).text
data = json.loads(txt) 76 77 data = json.loads(txt)