当前,我正在一个学期项目中,在这个项目中,我必须从facebook提取数据,但在获取用户访问令牌后要在GraphAPIError中运行以下python代码时,我拥有一个facebook开发人员帐户:必须使用活动访问令牌来查询当前用户的信息。即使我一次又一次获取新鲜的令牌,并且当我尝试在此处https://developers.facebook.com/tools/debug/accesstoken/https://developers.facebook.com/tools/debug/accesstoken/调试访问令牌时,它显示令牌将在一个小时后过期。请帮帮我 这是代码
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 15 10:12:18 2018
@author: Hasnain Khan
"""
# Chap04/facebook_my_profile.py
import os
import json
import facebook
import request
import json
if __name__ == '__main__':
token = os.environ.get('here i put my user access token')
graph = facebook.GraphAPI(token)
profile = graph.get_object('me', fields='name,location')
print(json.dumps(profile, indent=4))
posts = graph.get_connections('me', 'posts')
while True:
try:
with open ('my_posts.jsonl', 'a') as f:
for post in posts['data']:
f.write(json.dumps(post)+'\n')
posts = requests.get(posts['paging']['next']).json()
except KeyError:
break