如何创建“共享”?在iframe Facebook应用程序中弹出


How do you create the "share" popup in an iframe Facebook app

我目前有以下方法,创建一个"共享url"本质上是代码插入到应用程序中的onclick="。

问题是,现在我们可以不再有Facebook的FBML应用程序,只有iframe -有一个库,我现在需要包括使这项工作?或者我应该修改代码吗?我已经谷歌过了,但答案普遍不确定,或者是为了强迫它工作而进行的反向操作。

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;
}

谢谢!:)

要在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>