想在Facebook上分享网站内容

时间:2015-01-06 07:07:59

标签: php facebook share

我在facebook分享中遇到了一个问题:我想在php上发布内容,标题,网址,但我无法发布除URL以外的所有内容。

我有一个在Facebook上分享的链接。

   <a onClick="window.open('http://www.facebook.com/sharer.php?s=100&amp;p[title]=
     <?=$forum_list['subject']; ?>&amp;p[summary]=
     <?= $forum_list['content'] ?>&amp;p[url]=
     <?php echo $url; ?>&amp;p[images][0]=
     <?php //$image;?>','sharer','toolbar=0,status=0,width=548,height=325');
       " href="javascript: void(0)">
     <img src="<?php echo BASE_URL; ?>img/face.png" />
   </a>

2 个答案:

答案 0 :(得分:0)

<!--use this meta tag -->

    <meta property="og:title" content="<?php echo $deal['deal_title'] ;?>" />
    <meta property="og:url" content="<?php echo $_SERVER['REQUEST_URI'];?>" />
    <meta property="og:image" content="http://domain.com/img/<?php echo $deal['deal_image']; ?>" />
    <meta property="og:image:type" content="image/jpeg" />
    <meta property="og:image:width" content="620" />
    <meta property="og:image:height" content="541" />

<!-- Put this ancor tag in your body -->
<a onclick="fb_Share();" title=" Facebook - Share And Earn"><img src="img/fb-earn.gif" alt=" Facebook - Share And Earn" width="299" height="60"></a>
<!-- use this Javascript -->

<script src="http://connect.facebook.net/en_US/all.js"></script>
   <script>
     function fb_Share(){
         FB.init({ 
            appId:'apID', cookie:true, 
            status:true, xfbml:true 
         });

         FB.ui({ method: 'feed',
                link: document.URL,
            },
            function(response) {
        if (response && !response.error_code) 
          {
               // you action    
          } 
       else 
           {
              alert(response);
          }
      }

            );
      }

      </script>

答案 1 :(得分:0)

sharer.php仅将URL作为参数,它直接从URL读取Op​​en Graph标记,您无法再动态设置任何内容。

有关特定Open Graph标记的详细信息:http://ogp.me/