Dynamically generate description for explicitly shared open graph story through FB.ui Share Dialog

五迷三道 提交于 2019-11-30 05:27:11

I figured it out. The main problem I was having is I was posting to me/objects (which would post an event to the user's activity log) when I should have been posting to app/objects (which would create the object but not post an event). Since posting to app/anything requires an access token, I had to change the initial call to happen on the server side in PHP:

$request = new FacebookRequest(  
null,  
'POST',  
'/app/objects/mynamespace:myobject', 
array(
        'access_token' => 'myaccesstoken',
    'object' => json_encode(array(
        'app_id' => myappid,
            'url' => 'myurl',
            'title' => 'mytitle',
            'image' => 'myimg',
            'description' => 'mydesc'
        ))
)
);
$response = $request->execute();
$obj = $response->getGraphObject();
echo $obj->getProperty('id');

From there I could use the JS script to post the object with the new ID to the user's feed.

Hope that prevents you from spending 2 and a half days trying to figure it out on your own like I did.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!