Currently this module has basic support for Open Graph meta tags (through fb_social_like sub module). One of the missing meta tags is og:image.
While this can be done it's not straightforward and also there is a question whether the Open Graph should be supported by this project or as a separate one (http://drupal.org/project/opengraph_meta, http://drupal.org/project/open_graph ). If another modules is used, uncheck "Output the facebook opengraph tags for the above content types" settings at admin/settings/fb/social/like.

CommentFileSizeAuthor
#13 linter.zip1.48 KBHLopes
#11 linter.zip1.49 KBHLopes
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

CobraMP’s picture

this would be great with the option to flip through a few found images to select the one you actually want posted

HLopes’s picture

After placing the meta tags, if your button isn't sending the proper image, try to put the url in here:

http://developers.facebook.com/tools/lint

After that, the button will display and send the proper image to facebook.

I have no clue why, but it works. I've added a cron_hook to the module that iterates through nodes and performs a request to that url, and now all my buttons are working everywhere (inside node, in views, teasers....).

Just FYI...

Sanka007’s picture

I placed the meta tags and put the url in http://developers.facebook.com/tools/lint, and now the proper image is sent to facebook, but I don't know how to add the cron hook to the module.

Any help please?

HLopes’s picture

This is the source code to add to "fb_social_like.module" file .

function fb_social_like_cron() {
	global $base_url;
	$result = db_query("SELECT * FROM {node} WHERE nid NOT IN(SELECT nid FROM {linted}) AND status = 1 LIMIT 0,60");
	if($result){
		while($tmp = db_fetch_array($result)){
			$nid = $tmp['nid'];
			if(fb_social_like_type($tmp['type'])){
				$url = drupal_lookup_path('alias',"node/".$nid);
				drupal_http_request("http://developers.facebook.com/tools/lint/?url=".$url);
			}
			db_query("INSERT INTO {linted} VALUES (%d)",$nid);
		}
	}
}

But before you use it you need to create a new table called "linted" with a int field called "nid" on your database.

Also, this is a workaround, and will take forever if your site has a lot of nodes, as it'll only process 60 nodes at a time.

Sanka007’s picture

Great, it works! Thanks for the help, really appreciate it.

HLopes’s picture

function fb_social_like_cron() {
	global $base_url;

	$types = array_filter(variable_get('fb_social_like_node_types', array()));
	foreach($types as $k => $v){
		$types[$k] = "'".$v."'";
	}
	$tp = stripslashes(implode(',',$types));

	$result = db_query("SELECT * FROM {node} WHERE nid NOT IN(SELECT nid FROM {linted}) AND status = 1 AND type IN(".$tp.") LIMIT 0,60");
	if($result){
    while($tmp = db_fetch_array($result)){
			$nid = $tmp['nid'];
			if(fb_social_like_type($tmp['type'])){
				$url = drupal_lookup_path('alias',"node/".$nid);
				drupal_http_request("http://developers.facebook.com/tools/lint/?url=".$url);
			}
			db_query("INSERT INTO {linted} VALUES (%d)",$nid);
		}
	}
}

Just some optimizations....

madany’s picture

It gives the warning:

user warning: Table 'drupalstore.linted' doesn't exist query: SELECT * FROM node WHERE nid NOT IN(SELECT nid FROM linted) AND status = 1 AND type IN('article','blog','faq','page','story','stores','products') LIMIT 0,60 in /public_html/sites/all/modules/fb_social/modules/fb_social_like/fb_social_like.module on line 223.

HLopes’s picture

But before you use it you need to create a new table called "linted" with a int field called "nid" on your database.
Dubber Dan’s picture

This looks really useful HLopes will it make it in to the next version of the module?

HLopes’s picture

I don't know, you should ask ferdi (the module maintainer).

It's not an essential function, though... The button should work without being linted. This is just a quick fix i've used in one of my websites.

For now, what i can do is pack this up in a standalone module to avoid the need to mess up with the database.

HLopes’s picture

FileSize
1.49 KB

Something like this will do it...

If you use this, you won't need to mess with the database.

Just enable the module, it'll do his thingy whenever cron is ran.

If you have already applied the functions in the comments above, you can still use the module, but it'll throw an error when enabling, having the database table already created.

Remember: do not test on production sites!

emmry’s picture

HLopes, thanks for your module! Unfortunately I have some issues with it.

First of all, there is a typo stating the name of the table in the linter.module: in two places it says "linted" where should say "linter". When cron is run this will cause an error saying table not found if not corrected.

With that corrected it seems to work fine - Facebook finds the correct images now for the nodes I've tried, however nothing is saved in the "linter" table. Haven't been able to figure out why. Since no recored of what has been "linted" is saved, perhaps all the nodes will be sent to Facebook every time cron is run?

HLopes’s picture

FileSize
1.48 KB

Hi there,

you're correct, there's a typo. And the reason it doesn't add anything to the database has to do with an modification i've made to the code above.

The version in this comment should fix all that.

And that's why you always should test in a test server :D

Thanks for the feedback!

emmry’s picture

Great, thanks for the fast response!

Strange that the images works better when the pages have been checked by that Facebook linter though...
I mean it's sole purpose is to check for valid code right?! :-)

venusrising’s picture

Wondering if anyone has made any headway getting this to work ? Not too sure if running something through facebook on a large site would be taxing to the server.

Summit’s picture

Subscribing, coming from http://drupal.org/node/1012112.
Greetings, Martijn

venusrising’s picture

This issue needs some serious help as an image is vital to the social graph.

HLopes’s picture

Not too sure if running something through facebook on a large site would be taxing to the server.

No, every cron run it will send 60 requests to Facebook's Linter Tool. It's like 60 people clicked on an external link on your webpage. Having all the content linted can take a while, though, depending on how often you run cron. The main concern on performance is the use of drupal_lookup_path function, as i've read somewhere that it is db intensive.

If you wish to increase the number of linted nodes per cron run edit the module and change the query.

$result = db_query("SELECT * FROM {node} WHERE nid NOT IN(SELECT nid FROM {linted}) AND status = 1 AND type IN(".$tp.") LIMIT 0,60");

Cheers

venusrising’s picture

It seems to be there should be a better way than taxing the server to run it through linter. Why not a node field that can be designated as OG image by default. So, if you have a CCK content type then you could say okay this field will be the OG image as a default so you do not have to do it manually.

WashingtonIsBroke’s picture

I spent an hour trying to get this to work... before, I was getting a choice of 4 images that were in my right column, not any image that was in my blog post. Once I followed the instructions, I got NO images showing. The lint link does show the proper image however. Anywho.. after an hour, I decided to try another blog enter and guess what? IT WORKS! lol

Now the only problem I see it, where I used to get apostrophes in the title, now I get '

I.E. "I found Barack Obama's photo album!" is turning out "I found Barack Obama 's photo album!"

www.WashingtonIsBroke.com

WashingtonIsBroke’s picture

Update: the correct image only shows up the first time you click on Share.

Note, the link (http://drupal.org/project/open_graph) in the opening takes you to the page and says..
Maintenance status: Abandoned
Development status: Obsolete

Is this something I need?

WashingtonIsBroke’s picture

Update: Image issue appears to be an issue with IE9. It's working fine with Chrome.