0

我在将 URL 变量传递到 Facebook 提要对话框时遇到问题。当我按下按钮时,我可以在链接中看到它,但是一旦我将它发布到 Facebook 上,我就会得到所有内容,直到&.

这是我的代码:

<a href="https://www.facebook.com/dialog/feed?
app_id=142170752632916&
redirect_uri=http://domain.com/&
link=$currentUrl&amp;
picture=http://fbrell.com/f8.jpg&amp;
name=$title&amp;
description=$description">Share</a>

$currentUrl = $_SERVER['REQUEST_URI'] ;

我的网址如下所示:

www.Domain_Name.com/index.php?subaction=showfull&id=1368007502&start_from=3&template=Default&#disqus_thread

一旦我在 Facebook 上发布它,我得到的链接是:

www.Domain_Name.com/index.php?subaction=showfull

并且没有传递 id 或其他属性。

我能做些什么来解决它?

编辑:

这是我尝试在提要上发布链接后得到的结果:

https://www.facebook.com/dialog/feed?%20%20app_id=142170752632916&%20%20redirect_uri=http://domain.com /&%20%20link=http://www.domain.com/FrontEnd/index.php?subaction=showfull&id=1368007502&start_from=3&template=Default&&%20%20picture=http://fbrell.com/f8.jpg&%20%20name=bbb&%20%20description=bbb
4

1 回答 1

1

查看 facebook 的文档后,似乎真正的魔力在于回调函数

function callback(response) {
          document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
        }

这是将附加参数添加?post_id=12345到 url的参数https://mighty-lowlands-6381.herokuapp.com/。因此,按照下面的示例,facebook 提供了确保回调函数中的参数为您想要的 URL 中的参数,即subaction=showfull&id=1368007502&start_from=3&template=Default&#disqus_thread

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:fb="https://www.facebook.com/2008/fbml">
  <head>
    <title>My Feed Dialog Page</title>
  </head>
  <body>
    <div id='fb-root'></div>
    <script src='http://connect.facebook.net/en_US/all.js'></script>
    <p><a onclick='postToFeed(); return false;'>Post to Feed</a></p>
    <p id='msg'></p>

    <script> 
      FB.init({appId: "YOUR_APP_ID", status: true, cookie: true});

      function postToFeed() {

        // calling the API ...
        var obj = {
          method: 'feed',
          redirect_uri: 'YOUR URL HERE',
          link: 'https://developers.facebook.com/docs/reference/dialogs/',
          picture: 'http://fbrell.com/f8.jpg',
          name: 'Facebook Dialogs',
          caption: 'Reference Documentation',
          description: 'Using Dialogs to interact with users.'
        };

        function callback(response) {
          document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
        }

        FB.ui(obj, callback);
      }

    </script>
  </body>
</html>
于 2013-05-13T20:35:18.933 回答