简体   繁体   中英

Need to change the caption using the javascript Facebook api to post to wall

I am using Facebook javascript to publish/post to user wall. HEre is my code below. Everytime user post to wall they get a screen like below. The problem is I am getting "www.facebook.com" in the caption after the Title text "Pandora-whichstar are you". Any idea how to either remove this permanently or change this to something more convenient?

The image

在此输入图像描述

The Code

/facebook: post to wall 
function publishWallPost() {
      var fbImg = $('.head .headerLeft p img')[0].src;
      var fbTxt = $('.head .headRight span.artistName').text();
      FB.ui({
          method: 'feed',
          name: 'Pandora - Which Star Are You',
          caption: 'Convenient caption text here?',
          description: 'I\'m ' + fbTxt + ' according to Pandora\'s Which Star Are You competition.\n Click on the title to find out which star you are!',
          link: 'https://www.facebook.com/pages/xxx/11111111111?sk=app_2222222222',
          picture: fbImg
        },
        function (response) {
          console.log('publishStory response: ', response);
        });
      return false;
}


window.fbAsyncInit = function () {
      FB.init({
        appId: '2222222222',
        status: true,
        cookie: true,
        xfbml: true
      });
};

(function () {
      var e = document.createElement('script');
      e.async = true;
      e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
      document.getElementById('fb-root').appendChild(e);
}());

If Facebook is not letting you set the caption for a link on Facebook.com, what you can do instead is create a page that does a 301 redirect to the Facebook page you want to share and use that URL as the link parameter.

If a 301 redirect won't work, you can do a javascript redirect instead, but the same principle still applies.

Do it like @Fisch told u. Build a site with an JS Redirect and use the OG Meta Tags.

https://developers.facebook.com/docs/opengraph/

If u give caption or don't give caption, Facebook scraps URL.
By mandate,Facebook Domains URLs are not scraped. Link 1
For URLs that cannot be scrapped mostly the caption is taken from Domain part.[For this is Facebook leave matter in users hands whether to go ahead with click or not.]

As Sahil, I am to afraid that "caption edit" is not possible.

you can't give the Facebook page link on web dialogue. you need to do what @Fisch and @Hackbard are telling you to do.

you need to give the link of some webpage that has following meta tags on it:

<meta property="fb:app_id" content="123456789(your Facebook app id)" />
<meta property="og:title" content="X  Y  Z"/>
<meta property="og:type" content="game" /> (this depends upon your Facebook settings)
<meta property="og:url" content="www.yourWebpageLink.com/toPullOffDetails" />
<meta property="og:site_name" content="YOUR SITE NAME"/>
<meta property="og:image" content="http://the_image_you_want_to_show_on_that_dialogue"/>
<meta property="og:description" content="This is X Y Z, the best example on the planet" /> 

Build a page with javascript redirect window.location('url') to your app page as others mentioned but you should not have to do something else. All of your configs look okay.

Disclaimer: Do not use server side redirect as facebook will find out the URL you need to use javascript redirect as scrappers do not execute javascript.

While sharing a facebook link, facebook gives the relevant caption (sometimes description also) by itself.

If you try some link other than facebook, and give caption parameter you can see your caption in the feed. So, am afraid that you cannot edit the caption in your case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM