Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook API: "Share" a post already posted on a page's wall?

I can't seem to find an answer for this. Probably my Google-fu is letting me down.

Is there a way to use FB's Graph API (or any other way), in order to "share" a page's post on an authenticated user's wall so that it will increment the "share number" as show in the attached photo?

share counter next to page's post

like image 449
Amer Avatar asked Oct 31 '12 01:10

Amer


People also ask

How do I share a Facebook post on API?

The way you do it is to use /feed edge and pass the post's url that you want to share as the link. Standard Fb permissions to the post you are sharing do apply.

How do you share a Facebook post on your website?

Post your link on your wall and News Feed In order to do this, you'll want to paste your website's URL in the post box. You can find the post box in your Facebook Business Page under 'posts. ' Once you paste your URL, wait for a featured image of your website and title to appear.

Can I post on Facebook using API?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.


2 Answers

Okay, my answer varies between "no" and "maybe" depending on how exactly you want to accomplish this.

Do you want it to be a programmatic, automated sharing mechanism entirely dependant on code, that doesn't require the User to actively share it?

If so, the answer is no. Actually it would also probably violate Platform Policy too, but it isn't possible.

Do you mind if it is a dialog-based share, that has inconsistent behaviour for different types of Page posts?

If so, you are in luck. Somewhat. There is a now-deprecated function called "sharer.php" which used to be used for the Share Button, when Facebook still supported that. Though this has been deprecated, it is very unlikely to be removed, but unfortunately it does mean there is no documentation around. Luckily though, it is really simple:

http://www.facebook.com/sharer.php?u=https://www.facebook.com/coca-cola/posts/10152033676358306

The above is an example of sharing a Post on the Coca Cola Facebook Page. You would want to URL encode the u parameter, of course. You could have this as a plain link, or you could attach it with Javascript to the onclick of a button. However, here come the caveats:

  • This only seems to work with posts that are not themselves 'share' posts, such as the one you posted a screenshot of.
  • I don't have a full list of the types that it does work with, but Status Updates work perfectly.

If you want to pursue this route anyway, here are my recommendations:

  • Using the Graph API Page object, pull in the /posts connection
  • Filter down to everything that is of type: status
  • To construct the link to this to use with sharer.php, either parse each Post ID of the type 12345678_987654321 into https://www.facebook.com/12345678/posts/987654321 or take the /actions/link field from each Post (there will be one for Comment and one for Like but they'll be both the same)
  • URLEncode this and use it with sharer.php as above
  • For Page Posts that are of type: link, grab the link field and just use that with sharer.php as above. This won't increment the Share count as you want, but it will properly re-share the link.

Hope some of this helps you, ultimately the answer that works best for you maybe the 'no'.

like image 134
Matthew Johnston Avatar answered Oct 11 '22 08:10

Matthew Johnston


Yes, you can share using the graph2 api. The way you do it is to use /feed edge and pass the post's url that you want to share as the link.

POST /v2.2/{page-id}/feed HTTP/1.1
Host: graph.facebook.com

link=https://www.facebook.com/{page_id}/posts/{post_id}

Permissions to the post you are sharing do apply.

https://developers.facebook.com/docs/graph-api/reference/v2.2/page/feed

like image 25
Taysky Avatar answered Oct 11 '22 08:10

Taysky