How do you pass in the title and the image for a facebook comments widget?
I'm using the facebook comments widget and for the most part, it's working but I have two issues.
In order to have the right title show on the wall post, I'm having to use the
<fb:title>
tag and this is making the actual title show up right above the comment box. I would have liked to use the title propery of but that doesn't seem to do anything. The safest thing seems to be using the<title>
property in the header but unfortunately, I have a page that sets the title of the page using javascript after some logic has been executed and different phps have been included so that option is not easy. Using javascript doesn't seem to have the same effect as setting the ti开发者_开发百科tle explicitly when I'm writing out the header.I still don't know what I have to do to have any control over what image gets posted on the facebook wall with the comment. I have a page with multiple lists on the side of the detail page and it seems like fb arbitrarily picks an image from one of the listings. Obviously, this is highly undesirable because a lot of times the comment and the image will have nothing to do with one another. I've read that using img_src in your header helps but that hasn't worked for me either.
Any suggestions?
Not sure if this is what you're looking for; as i was confused to what your question was.
But if you're trying to set and provide a title/image for when someone comments on your page you may want to review the Open Graph protocol.
Not sure why you're setting your title with javascript; but if you use the meta tags you can get more granularity and provide facebook with a desired title and desired image.
Example (From Open Graph Documentation):
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock"/>
<meta property="og:type" content="movie"/>
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/"/>
<meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>
<meta property="og:site_name" content="IMDb"/>
<meta property="fb:admins" content="USER_ID"/>
<meta property="og:description"
content="A group of U.S. Marines, under command of
a renegade general, take over Alcatraz and
threaten San Francisco Bay with biological
weapons."/>
So lets break this down:
You want to set an image:
<meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>
Set a title for Facebook to parse:
<meta property="og:type" content="movie"/>
Make sure you set your xmlns:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml">
精彩评论