简体   繁体   中英

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? 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. So, it might look something like this in the 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.

You have some options:

sharer.php

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/

Creates a share dialog. More options for description and image etc. Might be a replacement for 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. Read more about authentication at https://developers.facebook.com/docs/authentication/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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