简体   繁体   English

分享PHP字符串到Facebook

[英]Share PHP string to Facebook

I was wondering if it was possible to use PHP / AJAX to have a string of text sharable to Facebook? 我想知道是否可以使用PHP / AJAX将一串文本共享到Facebook? For example, I use PHP to return an SQL query, then use that same string of text in correspondence with a button, to share to my Facebook wall. 例如,我使用PHP返回一个SQL查询,然后使用与按钮对应的同一字符串来共享到我的Facebook墙上。 So, it might look something like this in the PHP: 因此,在PHP中可能看起来像这样:

while($note_row = mysql_fetch_row($result)) {

echo '<p> "' . $note_row['my_note_text'] . ' "</p>';

echo '<input type="button" id="' . $note_row['my_note_id'] . '" class="share-to-facebook" value="share" />';

}

If anyone has some advice whether this is possible I'd be super happy. 如果有人对这是否可行有任何建议,我将非常高兴。 I also apologise if my PHP is wrong, I haven't checked it. 我也很抱歉,如果我的PHP错误,我还没有检查。

You have some options: 您有一些选择:

sharer.php sharer.php

https://www.facebook.com/note.php?note_id=407822831963 https://www.facebook.com/note.php?note_id=407822831963

Create a share link. 创建一个共享链接。 You can set title and url. 您可以设置标题和网址。

Feed Dialog 提要对话框

https://developers.facebook.com/docs/reference/dialogs/feed/ https://developers.facebook.com/docs/reference/dialogs/feed/

Creates a share dialog. 创建一个共享对话框。 More options for description and image etc. Might be a replacement for sharer.php. 更多描述和图像等选项。可以替代sharer.php。

If you need to post to the wall from your app, you need the get permissions by having the user accept your app to Facebook. 如果您需要从应用程序发布到墙上,则需要让用户接受您的应用程序到Facebook,以获得获取权限。 Read more about authentication at https://developers.facebook.com/docs/authentication/ https://developers.facebook.com/docs/authentication/上了解有关身份验证的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM