Set text in facebook API sharing

Asked

Viewed 445 times

0

I have a script to share content on Facebook is working well just wanted to add a text that the system generates automatically by clicking the share button.

Example:

I wish where it says Diz algo sobre isto… is a default text.
It is possible to do this ?

Code used

 <script>
  FB.init({appId: "", status: true, cookie: true, xfbml:true });

  function postToFeed(description) {

    var obj = {
        method: "feed",
        message     : "Vê este comentário sobre '.$row_estabelecimento->titulo.' no @SabeOnde",
        link        : "'.$row_estabelecimento->link_site.'",
        picture     : "http://sabeonde.pt/gtm/anexos/capa/'.$row_estabelecimento_anexo->id_anexo.'.'.$row_estabelecimento_anexo->tipo.'",
        name        : "'.$row_estabelecimento->titulo.' | SabeOnde",
        description : "'.$row_posts->opiniao.'",
        display: "popup"
    };

    function callback(response) {
      document.getElementById("msg").innerHTML = "Post ID: " + response["post_id"];
    }

    FB.ui(obj, callback);
  }
</script>

1 answer

1

You can’t do this using Sharer.php, but you can do something similar using API dialogue.

inserir a descrição da imagem aqui

EXAMPLE:

APP_ID = Facebook app Identifier    
"http://www.THEPAGE.com" = This would be my domain

    $('#share_button').bind('click', function(e){
            e.preventDefault();
            var title = 'Title I want';
            var im_url = 'url_to_image';
            url = "https://www.facebook.com/dialog/feed?app_id=APP_ID" + 
                        "&link=" + encodeURIComponent("http://www.THEPAGE.com")+ 
                        "&name=" + encodeURIComponent(title) + 
                        "&caption=" + encodeURIComponent('Shared from MY_PAGE') + 
                        "&description=" + encodeURIComponent('DESCRIPTION') + 
                        "&picture=" + encodeURIComponent("http://www.THEPAGE.com" +im_url) +
                        "&redirect_uri=https://www.facebook.com";
            window.open(url);
        });

See more!

source

  • Thank you I will make a test and then return the result

  • Didn’t help? Didn’t solve?

  • I had to see but I think my script is just like I’m gonna put up to see

  • So with this script I had to test and happens the same script I had

Browser other questions tagged

You are not signed in. Login or sign up in order to post.