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

前端 未结 1 602
走了就别回头了
走了就别回头了 2020-12-29 17:29

Of all of the research I\'ve done on this topic, 90% of it is outdated, which brings me to believe there have been recent changes to the Facebook JS SDK regarding explicitly

相关标签:
1条回答
  • 2020-12-29 18:21

    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.

    0 讨论(0)
提交回复
热议问题