how to share page post using facebook api

8.3k views Asked by At

There is very good and simple answer for question "how to hide page post using facebook api". Thanks a lot. Question "i want to share friend's post via graph api" still has no answer. How come?! :)

Does anybody know how to share Post (via Graph API) from some Page (on any possible destinations: Your timeline, friends timeline, in a group …)?! Any reference to Facebook documentation will be highly appreciated.

2

There are 2 answers

2
May Bogus On

Thanks to Maria Lucinda da Fonseca: https://groups.google.com/forum/#!topic/restfb/a94wO_KyZUM

String _destination = "me/feed"; // or "Page_id/feed"
String _linkToPost = ...;// here should be FQL stream.permalink see link to FB doc below
FacebookType publishMessageResponse =
  facebookClient.publish(_destination, FacebookType.class,
    Parameter.with("message", "Your message is here"),Parameter.with("link", _linkToPost ));

Also, you can share a LINK by exactly the same way: just change _destination to "me/links" or "page_id/links" and replace _linkToPost with real URL from browser or FQL link.url

FQL STREAM object

FQL LINK object

0
B.Adler On

Graph api sharedposts edge

according to the above link "You cannot publish shares of an object using the Graph API."

When you attempt to use the answer provided in Maria Lucinda da Fonseca's post, Facebook graph api responds with a user error message of

"error_user_msg": "One or more of the given URLs is not allowed by the Stream post URL security app setting. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains. Read https://developers.facebook.com/docs/facebook-login/security/ to learn more about app settings related to security."

While it is possible to share links using the graph api, sharing facebook links is not allowed.