dongmeba4877 2013-05-13 19:55
浏览 51

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

I'm having a problem passing my URL variables to the Facebook feed dialog. I can see it in the link when I press the button, but once I post it on Facebook, I get everything until the &.

Here's my code:

<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'] ;

My URL looks like this:

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

Once I post it on Facebook, I get the link as:

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

And no id or other attributes are passed.

What can i do to fix it?

Edit:

Here's what I get once I try to post my link on the 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条回答 默认 最新

  • dongtao6842 2013-05-13 20:35
    关注

    After looking at the facebook's documentation, seems like the real magic is in the callback function

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

    This is the one that adds the additional paramenter ?post_id=12345 to the url https://mighty-lowlands-6381.herokuapp.com/ . Thus follow the example below that facebook provides ensuring the parameters in the callback function to the one that you want in your URL, namely 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>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥20 关于变压器的具体案例分析
  • ¥15 生成的QRCode圖片加上下載按鈕
  • ¥15 板材切割优化算法,数学建模,python,lingo