English 中文(简体)
使用 Python Facebook SDK 发布 Open 图表动作
原标题:Using Python facebook SDK for posting Open Graph action

我可以使用 Facebook Python SDK 来发布一个打开的图形动作。 由于 Python facebook SDK 已经非常老了, 我怎么能用它来发布一个打开的图形动作呢?

最佳回答

您可以在Facebook 3党库中使用 Python 的 GrapAPI.request( self, path, args=None, post_ args=None) 功能, 用于Facebook 3党库( http:// www. pythonforfacebook.com/) 。 只需在 Facebook 开发者网站使用文件, 以构建 API 呼叫所需的 < code> path 、 < code>args 和 < code> post_args 。

问题回答

使用来自 Pip 的facebook- sdk 软件包, 您可以通过 put_ object call 发布动作

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

you can use https://github.com/zetahernandez/facebook-python-sdk it supports doing simple request like

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 = 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




相关问题
How do i redirect to a GET request from a POST request on GAE

i am writing an FBML app on facebook hosted in GAE. Facebook will talk to your hosted app only vai POST (im sure this is the cause, but please do correct me if i m wrong). So im faced with the issue ...

Facebook Graph API: user gender

The old Facebook API provided the user sex/gender as part of the default user data. Apparently the new Graph API does not provide that information, even though the documentation says that it does. I ...

Send private messages to friends

I need to get via Facebook connect user s info and send a private message to all of his friends. Is it possible?

Facebook Canvas multiple pages?

Is it not possible to move between pages in the canvas on facebook? I m trying to create a app where i have two pages that the users can switch between. The first page works fine, but when i click a ...

Getting a friend count from Facebook (possibly using api)

I m used to working with Twitter, where friend/follower totals are available in a simple XML request. My goal is a simple "enter your username/user id, and display your friends count". Is there ...

热门标签