2012-05-23 81 views

回答

1

您可以使用Python for Facebook第三方庫(http://www.pythonforfacebook.com/)中的GraphAPI.request(self, path, args=None, post_args=None)函數。只需按照Facebook開發者網站上的文檔來構建進行API調用所需的pathargspost_args即可。

1

從點子,你可以張貼與put_object呼叫動作

facebook.GraphAPI(token).put_object("me", "my_app:my_action", "my_object_type"="http://my_objects_url") 
+0

my_object_type =「..」工作正確(已刪除的參數重複e引號) – hurturk

0

可以使用https://github.com/zetahernandez/facebook-python-sdk 它支持做簡單的要求如

facebook = Facebook(
    app_id='{app_id}', 
    app_secret='{app_secret}', 
    default_graph_version='v2.5', 
) 

facebook.set_default_access_token(access_token='{access_token}') 

try: 
    response = facebook.get(endpoint='/me?fields=id,name') 
except FacebookResponseException as e: 
    print e.message 
else: 
    print 'User name: %(name)s' % {'name': response.json_body.get('id')} 

或批量請求使用Facebook的SDK包

facebook = Facebook(
    app_id='{app_id}', 
    app_secret='{app_secret}', 
) 

facebook.set_default_access_token(access_token='{access_token}') 

batch = { 
    'photo-one': facebook.request(
     endpoint='/me/photos', 
     params={ 
      'message': 'Foo photo.', 
      'source': facebook.file_to_upload('path/to/foo.jpg'), 
     }, 
    ), 
    'photo-two': facebook.request(
     endpoint='/me/photos', 
     params={ 
      'message': 'Bar photo.', 
      'source': facebook.file_to_upload('path/to/bar.jpg'), 
     }, 
    ), 
    'photo-three': facebook.request(
     endpoint='/me/photos', 
     params={ 
      'message': 'Other photo.', 
      'source': facebook.file_to_upload('path/to/other.jpg'), 
     }, 
    ) 
} 

try: 
    responses = facebook.send_batch_request(requests=batch) 
except FacebookResponseException as e: 
    print e.message