2016-08-05 1 views
-2

나는 아래의 코드에서 언급 한 파이썬 스크립트를 사용하여 페이스 북의 메시지를 가져 오는에 시도 :이 스크립트를 실행에오류 메시지 "(# 12) FQL는 버전 2.1에 대한 사용되지 않으며 높은"

#!/usr/bin/python 


import sys 

from facepy import GraphAPI 
from facepy import exceptions 

#Acces token with expire time = 60days 
LONG_LIVE_ACCESS_TOKEN = 'EAAZA7IlqBfvkBAKOjc7esSqY1VRJdsMkZC6QXM2mVlAwZAWjOiZA2ywalERBjLk4tzvZBu8JvoWvLRGcTtyZAGl482ueUI1o6MWjkK44y3TeoVKjYBayO5DSIP3Q1poVEa8hO8xZAXdScohEAgiFTtpvVQGk2nZB694ZD' 

#Facebook app id and secret from http://developer.facebook.com/apps 
APP_ID = '1824237337804537' 
SECRET_KEY = 'ee788eb9bea6d36f5f40e52530248f55' 

def user_id_to_username(userid): 

    """ Function to convert facebook USERID to username. """ 

    if userid is not None: 

     userid = '/{0}'.format(userid) 
     try: 
      return graph.get(userid)['name'] 

     except (exceptions.FacebookError, exceptions.OAuthError) as e: 
      print e.message 
      sys.exit(0) 

def get_message_author(message_list): 
    return user_id_to_username(message_list['snippet_author']) 


def get_message_author_id(message_list): 
    return message_list['snippet_author'] 


def get_message_body(message_list): 
    return message_list['snippet'] 


def get_recipients_list(message_list): 
    author = get_message_author_id(message_list) 
    temp = message_list['recipients'] 
    temp.remove(author) 
    return ", ".join(map(user_id_to_username, temp)) 


def pretty_print(message_list): 
    for message in message_list: 
     print "from:  ", get_message_author(message) 
     print "to:  ", get_recipients_list(message) 
     print "Message: ", get_message_body(message) 
     print "-" * 140 

graph = GraphAPI(LONG_LIVE_ACCESS_TOKEN) 

#Output of the facebook query language(FQL) 
#This FQL queries for message body, author, recipients for unread messages. 

try: 
    json_output = graph.fql('SELECT snippet, snippet_author, recipients FROM thread WHERE folder_id = 0 and unread != 0 Limit 4') 
except exceptions.OAuthError as e: 
    print e.message 
    sys.exit(0) 


message_list = json_output['data'] 

if message_list: 
    pretty_print(message_list) 
else: 
    print "No New Messages" 
    sys.exit(0) 

(# 12) FQL은 버전 2.1에 대한 사용되지 않으며 높은

+0

매우 구체적인 오류 messasge에 대해 명확하지 않은 점은 무엇입니까? – luschn

답변

0

FQL는 사용되지 않으며 Augus에 의해 페이스 북에 의해 완전히 지원되지 않는 것 : 오류 메시지를 보여줍니다 t 8, 2016 Facebook Query Language (FQL) Reference :

년 8 월 8, 2016로, FQL는 더 이상 사용할 수 없습니다 및 조회 할 수 없습니다. 앱을 이전하려면 API 업그레이드 도구를 사용하여 대신 수행 할 수있는 그래프 API 호출을 확인하십시오.

관련 문제