0

I'm working with facebook share. Here is my sample code:

function fbShare(url, title, descr, image, winWidth, winHeight) { var winTop = (screen.height / 2) - (winHeight / 2); var winLeft = (screen.width / 2) - (winWidth / 2); window.open('http://www.facebook.com/sharer.php?s=100&p[title]=' + encodeURIComponent(title) + '&p[summary]=' + encodeURIComponent(descr) + '&p[url]=' + encodeURIComponent(url) + '&p[images][0]=' + encodeURIComponent(image), 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight);return false; } 

I have some article want to share to facebook. there are some article successful with title, content and image. but some article share title or content only. I have checked my meta tag that was fine. So i don't know what happens now. Can anybody help me?

Thanks a lot.

2 Answers 2

1

I don't think you can set the desired image directly by passing the info via HTTP GET method, Facebook uses a set of Open Graph tags (see section 3) to determine the data in their Share Dialog.

In order to set the desire image to be displayed, you should include the following meta tag in the header section of the HTML code of the webpage that you want to share:

<meta property="og:image" content="http://www.example.com/img-to-be-shared.jpg"/> 


You may also take a look at this official documentation for sharing: Facebook Share Dialog

Sign up to request clarification or add additional context in comments.

1 Comment

i found that because my url haven't change and cache the index data. So i change the url link with get method to pass the id then facebook can get my web image and content.
0

If you want to share something through Facebook there is 2 ways to do it using the 1)share dialog[this does not allow much customization] 2)using open graph api calls[post that appear can be customized completely]. please refer the following post which will help you.
FB.getLoginStatus() called before calling FB.init() and this
Facebook share custom story on my timeline using javascript sdk or the official documentation is also helpful https://developers.facebook.com/docs

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.