Facebook表单提要对话框 - 链接属性出错

时间:2013-05-13 19:55:13

标签: php html facebook

我在将URL变量传递到Facebook Feed对话框时遇到问题。当我按下按钮时,我可以在链接中看到它,但是一旦我在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或其他属性。

我该怎么做才能解决它?

编辑:

这是我尝试在Feed上发布链接时获得的内容:

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

1 个答案:

答案 0 :(得分:1)

在看了facebook的documentation后,似乎真正的魔法在回调函数中

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

这是将附加参数?post_id=12345添加到网址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>