Facebook JavaScript SDK: FB.ui opens a popup window

后端 未结 6 1512
深忆病人
深忆病人 2021-02-13 23:10

I am trying to show a \'Post to Your Wall\' feed dialog with the following code in a facebook iframe app:

6条回答
  •  时光说笑
    2021-02-14 00:03

    There's a "URL Redirection" section in the docs for the Feed Dialog:

    https://www.facebook.com/dialog/feed?
      app_id=145634995501895
      &display=popup&caption=An%20example%20caption 
      &link=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2F
      &redirect_uri=https://developers.facebook.com/tools/explorer
    

    So you can do window.location=(this url) in Javascript, setting the redirect_url correctly, and this should work without a popup.

    Note that the Feed Dialog is now deprecated in v2.0, so check out the Share Dialog instead:

    To share a link:

    https://www.facebook.com/dialog/share?
      app_id=145634995501895
      &display=popup
      &href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2F
      &redirect_uri=https%3A%2F%2Fdevelopers.facebook.com%2Ftools%2Fexplorer
    

    To share an Open Graph story:

    https://www.facebook.com/dialog/share_open_graph?
      app_id=145634995501895
      &display=popup
      &action_type=og.likes
      &action_properties=%7B%22object%22%3A%22https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2F%22%7D
      &redirect_uri=https%3A%2F%2Fdevelopers.facebook.com%2Ftools%2Fexplorer
    

    The 'display=popup' bit affects how the share screen looks, it doesn't open a new window. Possible values for display are:

    async, iframe, page, popup, touch, wap
    

提交回复
热议问题