如何使用 PHP 在 Facebook 中分享帖子?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13117362/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:48:33  来源:igfitidea点击:

How to share post in Facebook using PHP?

phpfacebook

提问by Div

I have 5 divs in my program and in each div, it contains different content and share on FB button. Now when I click on this button, I need to share that particular content on FB. How can I do that?

我的程序中有 5 个 div,在每个 div 中,它包含不同的内容并在 FB 按钮上共享。现在,当我单击此按钮时,我需要在 FB 上分享该特定内容。我怎样才能做到这一点?

回答by VibhaJ

There are 2 ways. Below links may help you. I am using code from this article.

有2种方式。以下链接可能对您有所帮助。我正在使用本文中的代码。

1) Using javascript:

1)使用javascript:

http://thinkdiff.net/facebook/new-javascript-sdk-oauth-2-0-based-fbconnect-tutorial/

http://thinkdiff.net/facebook/new-javascript-sdk-oauth-2-0-based-fbconnect-tutorial/

2) Graph API

2)图形API

http://thinkdiff.net/facebook/php-sdk-3-0-graph-api-base-facebook-connect-tutorial/

http://thinkdiff.net/facebook/php-sdk-3-0-graph-api-base-facebook-connect-tutorial/

回答by Svetoslav

FB php SDK: https://developers.facebook.com/docs/reference/php/

FB php SDK:https: //developers.facebook.com/docs/reference/php/

This is full FB documentation for their PHP API.

这是他们 PHP API 的完整 FB 文档。

回答by Varun Bansal

Try this

尝试这个

 <?php
                    $title=urlencode('Dressfinity');
                    $url=urlencode('http://www.facebook.com/pages/Dressfinity-LLC/208406062583392 ');
                    $image=urlencode('http://livemarketnews.com/dressfinity/skin/frontend/default/default/images/logo.jpg');
                ?>
                <a onClick="window.open('http://www.facebook.com/sharer.php?s=100&amp;p[title]=<?php echo $title;?>&amp;p[url]=<?php echo $url; ?>&amp;&p[images][0]=<?php echo $image;?>', 'sharer', 'toolbar=0,status=0,width=548,height=325');" target="_parent" href="javascript: void(0)">
                    Share our Facebook page!
                </a>

For each div.

对于每个 div。