Facebook share link - can you customize the message body text?

前端 未结 7 2150
我寻月下人不归
我寻月下人不归 2020-12-02 17:17

I\'m trying to create a link that will share a page on Facebook. So far I\'ve got:

href=\"http://www.facebook.com/sharer.php
?u=http%3A%2F%2Fwww.cnn.com%2F
         


        
相关标签:
7条回答
  • 2020-12-02 17:38

    Like @Ardee said you sharer.php uses data from the meta tags, the Dialog API accepts parameters. Facebook have removed the ability to use the message parameter but you can use the quote parameter which can be useful in a lot of cases e.g.

    https://www.facebook.com/dialog/share?
    app_id=[your-app-id]
    &display=popup
    &title=This+is+the+title+parameter
    &description=This+is+the+description+parameter
    &quote=This+is+the+quote+parameter
    &caption=This+is+the+caption+parameter
    &href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2F
    &redirect_uri=https%3A%2F%2Fwww.[url-in-your-accepted-list].com
    

    Just have to create an app id:

    https://developers.facebook.com/docs/apps/register

    Then make sure the redirect url domain is listed in the accepted domains for that app.

    0 讨论(0)
  • 2020-12-02 17:39

    NOTE: @azure_ardee solution is no longer feasible. Facebook will not allow developers pre-fill messages. Developers may customize the story by providing OG meta tags, but it's up to the user to fill the message.

    This is only possible if you are posting on the user's behalf, which requires the user authorizing your application with the publish_actions permission. AND even then:

    please note that Facebook recommends using a user-initiated sharing modal.


    Have a look at this answer.

    0 讨论(0)
  • 2020-12-02 17:47

    To add some text, what I did some time ago , if the link you are sharing its a page you can modify. You can add some meta-tags to the shared page:

    <meta name="title" content="The title you want" />
    <meta name="description" content="The text you want to insert " />
    <link rel="image_src" href="A thumbnail you can show" / >
    

    It's a small hack. Although the old share button has been replaced by the "like"/"recommend" button where you can add a comment if you use the XFBML version. More info her:

    http://developers.facebook.com/docs/reference/plugins/like/

    0 讨论(0)
  • 2020-12-02 17:49

    Facebook does not allow you to change the "What's on your mind?" text box, unless of course you're developing an application for use on Facebook.

    0 讨论(0)
  • 2020-12-02 17:50

    You can't do this using sharer.php, but you can do something similar using the Dialog API. http://developers.facebook.com/docs/reference/dialogs/

    http://www.facebook.com/dialog/feed?  
    app_id=123050457758183&  
    link=http://developers.facebook.com/docs/reference/dialogs/&
    picture=http://fbrell.com/f8.jpg&  
    name=Facebook%20Dialogs&  
    caption=Reference%20Documentation& 
    description=Dialogs%20provide%20a%20simple,%20consistent%20interface%20for%20applications%20to%20interact%20with%20users.&
    message=Facebook%20Dialogs%20are%20so%20easy!&
    redirect_uri=http://www.example.com/response
    

    Facebook dialog example

    The catch is you must create a dummy Facebook application just to have an app_id. Note that your Facebook application doesn't have to do ANYTHING at all. Just be sure that it is properly configured, and you should be all set.

    0 讨论(0)
  • 2020-12-02 17:50

    Like said in docs, use

    <meta property="og:url"           content="http://www.your-domain.com/your-page.html" />
    <meta property="og:type"          content="website" />
    <meta property="og:title"         content="Your Website Title" />
    <meta property="og:description"   content="Your description" />
    <meta property="og:image"         content="http://www.your-domain.com/path/image.jpg" />
    

    image size recommended: 1 200 x 630

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