2012-01-25 3 views
3

내 Facebook 앱에서 토네이도 프레임 워크를 사용하는 사용자에게 앱 요청을 보내려했습니다. http://www.tornadoweb.org/documentation/auth.html을 따라했지만이 오류를 해결하는 방법을 모릅니다. 밖에있는 전문가가 있습니까? 감사! 당신이 tornado.web.RequestHandler를 서브 클래스 깜빡 같은토네이도 프레임 워크 (FacebookGraphMixin)

오류 로그

Traceback (most recent call last): 
    File "send.py", line 36, in <module> 
    main() 
    File "send.py", line 33, in main 
    test.get(app_access_token, player_id) 
    File "send.py", line 15, in get 
    callback=self.async_callback(self._on_post)) 
AttributeError: 'Send' object has no attribute 'async_callback' 

코드

import tornado.auth 
import tornado.escape 
import tornado.httpserver 
import tornado.ioloop 
import tornado.options 
import tornado.web 
from tornado import httpclient 

class Send(tornado.auth.FacebookGraphMixin): 
    def get(self, app_access_token, player_id): 
     self.facebook_request(
      "/"+player_id+"/apprequests", 
      post_args={"message": "I am an app request from my Tornado application!"}, 
      access_token=app_access_token, 
      callback=self.async_callback(self._on_post)) 

    def _on_post(self, new_entry): 
     if not new_entry: 
      # Call failed; perhaps missing permission? 
      self.authorize_redirect() 
      return 
     self.finish("Posted a message!") 

def main(): 
    key = "xxxxxxxxxxx" 
    secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 
    player_id = "100003395454290" #fake id 
    http_client = httpclient.HTTPClient() 
    response = http_client.fetch("https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id="+key+"&client_secret="+secret+"&redirect_uri=&code=") 
    app_access_token = response.body.replace("access_token=","") 

    test = Send() 
    test.get(app_access_token, player_id) 

if __name__ == "__main__": 
    main() 

답변

0

보인다. 변경 :

class Send(tornado.auth.FacebookGraphMixin): 

사람 :

class Send(tornado.web.RequestHandler, tornado.auth.FacebookGraphMixin): 
+0

안녕하세요, 감사합니다. Rob! 하지만 토네이도없이 이것을 할 수있는 방법이 있습니다. 웹. 요청자입니다. – yori

+0

@yori,'async_callback'은'tornado.web.RequestHandler'의 메소드입니다. 그래서 당신은 그 메소드를 사용하지 않고 그것을 수행 할 방법을 찾아야 할 것입니다. –

+0

궁금한 점이 ... 토네이도를 사용하지 않고도 가능하다고 생각하십니까? 웹입니다. 요청 해 드리겠습니다. 내 상사가 tornado.web를 사용하지 말라고 요청했습니다 .RequestHandler :(이유가 약간 분실되었습니다.) – yori

1

좋아, 내 대답은 직접 영업 이익의 질문에 대답하지 않습니다. 그러나 이것은 오류에 대한 상위 검색 결과에 표시됩니다. AttributeError: 'XxxxxHandler' object has no attribute 'async_callback'

토네이도 v4.0 시작은 async_callback 기능이 제거되었습니다. 인용 할 수있는 Backwards-compatibility notes :

RequestHandler.async_callbackWebSocketHandler.async_callback 래퍼 함수가 제거 된; 그들은 스택 컨텍스트 (그리고 최근에 coroutines) 때문에 오랫동안 에 대해 폐기되었습니다.