Open Graph Protocol is described here: http://developers.facebook.com/docs/opengraph

It is a Facebook initiative and used by at least Facebook (but not limited to them).

The following is an excerpt from that page:

---------

The Open Graph protocol defines five required properties:

* og:title - The title of your object as it should appear within the graph, e.g., "The Rock".
* og:type - The type of your object, e.g., "movie". See the complete list of supported types.
* og:image - An image URL which should represent your object within the graph. The image must be at least 50px by 50px and have a maximum aspect ratio of 3:1.
* og:url - The canonical URL of your object that will be used as its permanent ID in the graph, e.g., http://www.imdb.com/title/tt0117500/.
* og:site_name - A human-readable name for your site, e.g., "IMDb"

In addition, we've extended the basic meta data to add one required field to connect your page with :

* fb:admins or fb:app_id - A comma-separated list of either Facebook user IDs or a Facebook Platform application ID that administers this page.

It's also recommended that you include the following property as well as these multi-part properties.

* og:description - A one to two sentence description of your page.

------------------

Example:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ceefour’s picture

Example:

<meta property="og:site_name" content="Soluvas"/>

Anonymous’s picture

Project: Nodewords: D6 Meta Tags » Extra meta tags modules
Version: 6.x-1.11 »

I am moving the feature request to the project that contains all the extra modules.

Exploratus’s picture

subscribe. Where was this moved???

benklocek’s picture

Subscribe. Wondering where also.

RasputinJones’s picture

FileSize
4.56 KB

Here you go. This is based on nodewords_nodetype.

You will need to update the core nodewords module to support outputting <meta property...> for og. Left as an exercise for the reader. :)

We probably should make a separate project out of this.

4v4l0n42’s picture

Subscribing.

Anonymous’s picture

Project: Extra meta tags modules » Nodewords: D6 Meta Tags
Version: » 6.x-1.x-dev
lolandese’s picture

toomanypets’s picture

Posted a custom module for adding Open Graph protocol meta tags here:
http://drupal.org/node/784904#comment-3582838

Dave Reid’s picture

Marked #836282: Integrating Open Graph protocol tags and meta tags are not working as a duplicate of this issue. If we need to patch the nodewords API to support Open Graph meta tags, we need to know that or see a patch.

Dave Reid’s picture

Status: Active » Postponed
sammys’s picture

Status: Postponed » Needs review

Here are two patches to bring Open Graphs support to nodewords. I've used the module posted in #5 as a base and:

  • rewrote most of it
  • added caching of the tags so the titles and descriptions can be used for the form widgets as well as the admin interface
  • added location, video and contact og tags
  • most importantly: patched nodewords core to support property meta tags.

It appears to be working nicely thanks to the hard work of the maintainers and testers getting nodewords ready for its next release. The API appears to be fairly easy to work with. Thanks to all of you!!!!

I'm marking this as 'needs review' so it gets reviewed by the community. Hope you all like it.

The module probably needs a bit more work on validation of the content and fine tuning the contexts but at least it works for now.

sammys’s picture

Got too excited and hit the save button before uploading the patches hehe. Here they are.

sammys’s picture

Here is an updated patch for adding meta property support. Just a small change to improve efficiency.

sammys’s picture

Ok. Some extra patch goodness ended up in the last patch so please use this one instead. It has been a LONG day. :)

dzepol’s picture

subscribe

Anonymous’s picture

Issue tags: -v6.x-1.12 blocker
  • -    $parts = explode(':', $name);
    +    // Check if it's a property meta tag
    

    Comments should have a final period.

  • +  if ($cached === 0) {
    +    $tagsrc = nodewords_og_get_tags();
    

    It's enough to use if (!$cached) {} which works also if the value returned by the function is a boolean value, which is a value the cache_get() function sometime returns.

  • +      $label = t('Open Graph: !labelsuffix', array('!labelsuffix' => (!empty($value['labelsuffix']) ? $value['labelsuffix'] : $key)));
    +      $tags[$key] = $value + array(
    

    The placeholder should probably start with @.

DamienMcKenna’s picture

Issue tags: +v6.x-1.12 blocker

Seeing as this seems pretty simple and has some work on a patch, lets get this into the next release.

sammys’s picture

@kiam:

cache_get() will never return a boolean value. The only possible return values are an object or integer 0. The notes below the docs for cache_get() state we should check for expired cache data.

The placeholder doesn't need to use @ because the values are not coming from a non-code source. A ! placeholder executes faster.

Add a period? A truly discouraging request. The person committing the code can surely take that matter into their own hands. Must I point out the complete lack of "thank you for the patches"?

Here are the updated patches.

sammys’s picture

Status: Needs review » Needs work

There appears to be a small bug preventing values saved for Facebook: AppID and Facebook: Admins from showing again in the admin forms. I'll fix this up asap.

ball.in.th’s picture

FYI, there's a similar module at http://drupal.org/project/opengraph_meta

Anonymous’s picture

  • $value['labelsuffix'] is the value set from a module, which could also request the value to the user; that would be a reason to use @ instead of !. Apart that, the variable could contain something that needs to be escaped before to be shown in HTML output.
  • The value returned from cache_get() is the value returned from db_fetch_object(), which (when the database engine is MySQL) invokes mysql_fetch_object().
    As reported in the documentation for mysql_fetch_object()

    Returns an object with string properties that correspond to the fetched row, or FALSE if there are no more rows.

    $cache === 0 would be evaluated to FALSE, if the returned value is FALSE.

kafka93’s picture

Sammy-- thanks for your efforts. I'm having a hard time getting it to work, though-- I'm not seeing any og fields show up in admin/content/nodewords -- is that where I should be looking? (I also don't see any og: tags added to the generated source). Any help/pointers to debugging would be much appreciated!

sammys’s picture

Status: Needs work » Needs review
FileSize
16.44 KB

Here is the updated patch with the FB App ID and Admins tags working properly. You need 803512_meta_property_20.patch from post #20 above along with this patch.

@kafka93: After you have applied the patches and installed the nodewords_og module you should be able to see the og fields in admin/content/nodewords. You then need to check the ones you want to see in edit forms and in the admin forms. After you've saved that you can edit the default values for those at admin/content/nodewords/default and then edit them on the node edit forms if you chose that option in the settings.

Bruno-2M’s picture

subscribe

naeluh’s picture

subscribe

leahmd’s picture

subscribe

naeluh’s picture

I tried to install nodewords_og module, because I am interested an putting this meta information my pages :

<meta name="title" content="" />
<meta name="description" content="" />
<link rel="video_src" href=""/>
<meta name="video_height" content="276" />
<meta name="video_width" content="420" />
<meta name="video_type" content="application/x-shockwave-flash" />
<link rel="image_src" href="" />
Parse error: syntax error, unexpected ')' in /var/www/sites/all/modules/nodewords_og/nodewords_og.module on line 448

I installed the patches but I keep getting this fatal error

Is there an easy way to add custom og meta data, could I just add it the top of the page in the header thanks

cookiesunshinex’s picture

subscribe

codevoice’s picture

As of the date of this post, the opengraph_meta does NOT support the following tags:

og:url
fb:admins

There is apparently no intention to support the second one, which is of particular concern since it's required for getting a lot of opengraph to work with facebook.

So hopefully this saves someone else some wasted time testing the module.

Dave Reid’s picture

OpenGraph <> Facebook - they are not the same things

It's the Facebook-specific implementation of OpenGraph that requires the fb:admins tag, so it should be a Facebook module that adds support for it.

amaria’s picture

On second thought I see that this is using the api...

Dave Reid’s picture

Issue tags: -v6.x-1.12 blocker

Bumping to 6.x-1.13 for now. I really, really want to get 6.x-1.12 out before we start adding new features.

mherchel’s picture

subscribe

..in the meantime I'll upgrade to the dev release to test.

Thanks for a great module!

joehudson’s picture

The patches don't apply to 1.x anymore. But they do apply to 2.0-alpha1
I enable nodewords_og module, but no og meta options appear on the nodewords settings page!

Looking in nodewords_og.module I was surprised to see only


<?php

/**
 * Implements hook_nodewords_api().
 */
function nodewords_og_nodewords_api() {
  return array(
    'version' => '1.14',
    'path' => '',
  );
}

Don't those new inc files need including somewhere?

joehudson’s picture

So far I can't find any way of getting this patch to work and the og features do not appear to be in the current dev 1.x or 2.x releases.. Nodewords has been really useful (thanks for the great module!), but I'm surprised there's not more demand for this feature. What other solutions do people use for Drupal?

lolandese’s picture

Hi Joe,
"What other solutions do people use for Drupal?"
I use the Add To Head module. You have to define your og tags per page, but it's simple, lightweight and working. You can use it also for other purposes like inserting Javascript or CSS into the head section of the page. Until there is something better that's stable, I go with it.

joehudson’s picture

Hi Martinus, thanks for that. Add To Head can certainly serve as a stop gap measure, until this patch is working.

tribe_of_dan’s picture

@sammys Thank you so much for these patches. They work great!! :)

It was confusing for me at first but I got it working with 2.0-alpha1.

It would be great to add the functionality to add default fields by node type.

mherchel’s picture

I'm attaching a patched version of 6.x-2.0-alpha1. This is manually patched, and it works for me.

mherchel’s picture

Comments after testing:

1. The token feature works great when specifying a CCK image on a content type that has an imagefield defined.
2. However, within the same D6 installation, when viewing a content type that does not have that particular imagefield associated with it, the module will generate the actual token in the OG Meta tag (example: <meta property="og:image" content="http://localhost:8082/[field_image-filefield-filepath]" />
3. There needs to be 1) a way to enable/disable specific OG meta tags per content type, and 2) a way to specify different default tokenized meta tags per content type.
4. This is looking awesome! This is badly needed functionality for Nodewords, and I cannot wait till this gets committed. Great job!

DamienMcKenna’s picture

I don't suppose you'd be interested in building a patch for 6.x-1.x? =) The status of the 6.x-2.x branch is still under debate.

mherchel’s picture

@Damien - I wish. Unfortunately, my PHP skills are about as great as my handyman skills (which is to say practically non-existent).

I'm willing to test and help out in other ways if I can, though.

DamienMcKenna’s picture

Status: Needs review » Needs work

Needs some work to backport it to the 6.x-1.x branch.

venusrising’s picture

With all the new announcements about Open Graph today has anyone found a way to add these tags to Nodewords?

neilnz’s picture

FileSize
17.36 KB

I've done a backport of #20 and #25 to the 1.x-dev branch, but it had to lose tokens support, as it seems the 1.x branch no longer includes the nodewords_replace_tokens() function. I agree that this is a bit annoying, but looking at the release notes, it seems the token support was yanked and moved to 2.x (and then abandoned?).

This'll do for some people in the meantime though.

The patch also includes a fix to the current dev release that breaks node support:

-      elseif ($options['type'] == NODEWORDS_TYPE_NODE || node_access('view', node_load($options['id']))) {
+      elseif ($options['type'] == NODEWORDS_TYPE_NODE && !node_access('view', node_load($options['id']))) {

Even though this isn't technically part of this feature, it's a bug that needs to be fixed in order for the current dev release to work.

ceefour’s picture

metatag (nodewords replacement for Drupal 7.x) already has built-in support for Facebook/OpenGraph tags.

venusrising’s picture

This issue is for Drupal 6 which many many sites still use.

neilnz’s picture

Status: Needs work » Needs review

Yeah agreed. Even if 2.x, with all its benefits, never sees the light of day, lots of people could benefit from being able to do OG with Nodewords, rather than one of the alternative modules, as they already use Nodewords for other tags.

Marking as needs review because I forgot to change the status when I reposted the patch for 1.x.

Status: Needs review » Needs work

The last submitted patch, 803512_nodewords_og_47.patch, failed testing.

DamienMcKenna’s picture

FileSize
17.41 KB

Rerolled against the latest codebase, could someone please help test this, if it works right I'd really like to get it in the next release.

DamienMcKenna’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, nodewords-n803512-52.patch, failed testing.

DamienMcKenna’s picture

Status: Needs work » Needs review

I believe the failure is because it installs a new module so the testbot won't like it.

DamienMcKenna’s picture

Status: Needs review » Needs work
FileSize
16.02 KB

Seems it definitely needs work - the tags get saved correctly but nothing is displayed. Also, I've moved the new "properties" meta tag type to its own issue: #1359988: Allow for meta property tags, so this just deals with the new nodewords_og files (and the README.txt update).

venusrising’s picture

I would be happy to test if it worked again the 6.x-1.11 version as we cannot change to dev to to so many issue and instability.. We have a sandbox replicating our production site.

DamienMcKenna’s picture

Status: Needs work » Needs review
FileSize
16.37 KB

Some changes:

  • Simplified the _prepare functions be adding a wrapper, which will get simplified further in #1370484: Simplify API by adding a default _prepare function .
  • Moved the tag hooks to the main module file rather than using an external file.
  • Tags can now be displayed on all page types, not just a few.
  • Tags can now have default values.

I've tested this one and there is data coming through, but maybe it should perform specific validation on each field?

DamienMcKenna’s picture

I've tested this a bit and it is outputting the tags, I'm considering just adding this to the current version and then improve it in the next version with data validation & more logic. Thoughts?

DamienMcKenna’s picture

FileSize
16.61 KB

Another update, this makes the Site Name only editable in the Defaults, along with a few minor code tweaks.

DamienMcKenna’s picture

Status: Needs review » Needs work

Big gotcha with this - the HTML tag itself has to be customized, specifically it needs an xmlns definition added, otherwise XHTML validation will fail and the tags themselves may not work (I stopped looking into it when I identified the XHTML validation problem). Bummer. So now we're going to need to include a message in hook_install to hack the template file, along with instructions in the README.txt file.

DamienMcKenna’s picture

Status: Needs work » Needs review
FileSize
18.75 KB

This patch includes a few more changes:

  • The main README.txt file has been updated to include a section explaining the theme customization that is necessary in order for this to work.
  • The nodewords_og module's description includes a mention of the customizations that are necessary and to check the README.txt file.
  • Upon installation a message is displayed telling the user to check the README.txt file for instructions on customizing the theme.

Not sure if anything else can be done at this point?

DamienMcKenna’s picture

Status: Needs review » Fixed

I decided to commit this after some initial testing which showed the tags to be at least outputting correctly, the question of whether the spec has changed since the patch was first written is a question for later.

Thanks to RasputinJones, sammys, mherchel and neilnz for their help with this, it really was a community effort :-)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.