我目前正在使用facebook GraphApi(使用facepy导入)来构建一个抓取工具,该抓取工具从不属于我的组中提取信息。由于facebook的API v2.5不支持从不属于我的组中提取信息,因此我被迫使用旧版本。我的问题是,考虑到我无法创建应用程序,如何延长我的个人令牌生命周期,因为它迫使我使用最新的API版本。我将删除以下代码:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import facebook
from facepy import GraphAPI
from facepy import get_extended_access_token
import json
import schedule
import time
group_id = "the group id" #grupo operações stop coimbra https://www.facebook.com/groups/operacaostopcoimbra/
access_token = "access token i took from facebook developers"
class Crawler():
def __init__(self, access_token):
self._access_token = access_token
def crawl(self):
graph = GraphAPI(self._access_token) #aceder à GraphAPI
extended_token = get_extended_access_token(access_token, APP ID, APP SECRET) #PROBLEM IS HERE!
print extended_token
data = graph.get(group_id + "/feed", page=False, retry=3, limit=25)
data = self._parseJson(data)
return data
def _parseJson(self, data):
if data["data"][0]["message"]:
return data["data"][0]["from"]["name"] + " " + data["data"][0]["from"]["id"] + " " + data["data"][0]["message"]
else:
return None
result = Crawler(access_token)
schedule.every(1).minutes.do(result.crawl())
while 1:
schedule.run_pending()
time.sleep(1)
答案 0 :(得分:0)
好像没有app,没有令牌......