【问题标题】:How do you create the "share" popup in an iframe Facebook app如何在 iframe Facebook 应用程序中创建“共享”弹出窗口
【发布时间】:2011-05-04 09:00:10
【问题描述】:

我目前有以下方法,它创建一个“共享网址”,本质上是插入应用程序内的 onclick="" 的代码。

问题是现在我们不能再拥有 Facebook FBML 应用程序,只有 iframe - 我现在需要包含一个库来使其工作吗?或者我应该更改代码,我已经用 Google 搜索过,但答案普遍没有定论,或者是回溯以迫使它工作。

public function getShareUrl($title, $url, $caption, $description, $imageSrc, $shareButtonText = 'Share your thoughts!')
{
    $url .= "var attachment = {
                    'name':'$title',
                    'href':'$url',
                    'caption':'$caption',
                    'description':'".$description."',
                    'media':[{
                        'type':'image',
                        'src':'$imageSrc',
                        'href':'$url'
                    }]
                };
                var actionLinks = [{
                    'text':'Join the app now',
                    'href':'$url'
                }];
                Facebook.streamPublish('', attachment, actionLinks, null, '$shareButtonText');
                return false;";
    return $url;
}

谢谢大家! :)

【问题讨论】:

    标签: php javascript facebook fbml fbjs


    【解决方案1】:

    要在您的 Facebook 应用程序中显示共享弹出窗口,您必须使用 Javascript SDK

    你可以这样做:

    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
      <head>
    <title></title>
    </head>
      <body>
      <div id="fb-root"></div>
    <script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
    <script type="text/javascript">
      FB.init({
       appId  : 'yourappid',
       status : true,
       cookie : true,
       xfbml  : true 
      });
    </script>
    <script type="text/javascript">
      function streamPublish(name, description, hrefTitle, hrefLink, userPrompt, imageSrc, imageUrl) {
          FB.ui({
              method: 'stream.publish',
              message: '',
              attachment: {
                  media: [{
                      type: 'image',
                      src: imageSrc,
                      href: imageUrl
                  }],
                  name: name,
                  caption: '',
                  description: (description),
                  href: hrefLink
              },
              action_links: [{
                  text: hrefTitle,
                  href: hrefLink
              }],
              user_prompt_message: userPrompt
          }, function (response) {
              // do something when you have posted
          });
      }
    
      function publishStream() {
          streamPublish("Stream Publish", 'sample publish', 'do something cool', 'http://example.com', "My fb app", 'http://bit.ly/AJTnf', 'http://bit.ly/hifZk');
      }
     </script>
    <p>Stream Publish Test</p>
    <a href="#" onclick="publishStream(); return false;">Post a story</a>
      </body>
    </html>
    

    【讨论】:

    • 我不能给你一个“一个”,但如果我的代表足够高,我会的。谢谢! :)
    • John Ennis,developers.facebook.com/docs/share 和你上面描述的方法有什么区别?
    猜你喜欢
    • 2013-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多