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

后端 未结 3 777
夕颜
夕颜 2021-02-08 03:02

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 pag

相关标签:
3条回答
  • 2021-02-08 03:14

    Are you using the new JS SDK? if so, please refer to this post

    "With the new JS SDK you can use the button and it will be rendered and usable but the supported types are less and you will lost the shared count if you used it."

    ref: Does the Facebook Share Button work with the New Javascript SDK?

    0 讨论(0)
  • 2021-02-08 03:20

    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'.

    0 讨论(0)
  • 2021-02-08 03:37

    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

    0 讨论(0)
提交回复
热议问题