Jump to content

Facebook Open Graph Meta Tags


tswitze

Recommended Posts

I'm trying to implement Facebook's open graph meta tags (see http://developers.facebook.com/docs/opengraph) on a 1.31.1 store and can't figure out how to generate the og:image tag.

This is the code I have so far. The code for the og:title and og:url are parsing the correct values but I have no idea what code to use to get the correct product image for the og:image tag

<html xmlns:og="http://opengraphprotocol.org/schema/"
     xmlns:fb="http://www.facebook.com/2008/fbml">


   <head>
.......

<meta property="og:title" content="{$meta_title|escape:'htmlall':'UTF-8'}"/>
   <meta property="og:type" content="product"/>
   <meta property="og:url" content="{php} echo 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; {/php}"/>
   <meta property="og:image" content=""/>
<meta property="fb:app_id" content="(your developer ID)"/>
   <meta property="og:site_name" content="(your site name)"/>

Link to comment
Share on other sites

  • 3 weeks later...

I'm not a presta developer, but in is the best image url for product, ok? So look to classes/Product and Product::getImages($lang) or Product::getCover($lang) which return product's cover image ID. If you have an ID of a image, you win.

Look at for example to modules/gsitemap to Gsitemap::_postProcess where are generated URLs to sitemap.xml, ones from cms pages, ones for products and ones for images. Ok, I think, that image URL is something like this:

$link = new Link();
ogImageUrl = 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').'/img/p'.$link->getImageLink($productId.'-'.$imageId);

I answered you?

I'm going to make something similar, but not now, to 3 months later... Do you place your plugin as opensource? I will be continuing in your work.

I'm trying to implement Facebook's open graph meta tags (see http://developers.facebook.com/docs/opengraph) on a 1.31.1 store and can't figure out how to generate the og:image tag.

This is the code I have so far. The code for the og:title and og:url are parsing the correct values but I have no idea what code to use to get the correct product image for the og:image tag

<html xmlns:og="http://opengraphprotocol.org/schema/"
     xmlns:fb="http://www.facebook.com/2008/fbml">


   <head>
.......

<meta property="og:title" content="{$meta_title|escape:'htmlall':'UTF-8'}"/>
   <meta property="og:type" content="product"/>
   <meta property="og:url" content="{php} echo 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; {/php}"/>
   <meta property="og:image" content=""/>
<meta property="fb:app_id" content="(your developer ID)"/>
   <meta property="og:site_name" content="(your site name)"/>

Link to comment
Share on other sites

  • 4 months later...
  • 2 months later...

Ok,

I'm sick today, for worst flu in my life so I had time to done this :)

download from

http://code.google.com/p/prestashop-facebook-opengraph-module/

Your contributions are very welcomed.

This is working plugin implementing META tags from

http://developers.facebook.com/docs/reference/api/

So if page is not product page, it displays site logo and og:type website. If a page is product's page, it displays product image (first from lang_id and product_id) and og:type product.

Enjoy!

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

If you're having trouble with this great mod, try editing fbopengraph.php and looking for this piece of code.

     //if language is present
    $id_lang = $_GET['id_lang'];
    if (!isset($id_lang)) {
      //if is not present, hardcode lang_id as in www.acidx.cz 
      //change this to whatever language code you actually use  
      $id_lang = 3;
    }
     if ($_DEBUG == 1) {
         echo 'IdLang: '.$id_lang.'';
     } 



I had to change $lang_id = 3 to $lang_id = 1 and then it worked fine for me.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...
  • 4 weeks later...

Hi guys

 

I have installed the module in my 1.3.1.1 and the Facebook Like button writes the Like to the wall, but an error appears, and the Like button count is 0.

 

"Applikasjons-IDen specifiied in meta tag "fb:app_id" is not alowed on that domain."

 

Please advice :)

Link to comment
Share on other sites

  • 5 months later...

Thanks for this!! I've already used it together with prestaloveaddthis module. This module if free for use, but...it has several disfunction like FB open graph, its not included. So I added fbopengraphmodule (I'm using PS 1.4.7 here http://www.luxusni-pradylko.cz) and I had also problems with images....I made change like DFC005 and now its working all fine :-)))

 

THX DFC005 for saving my time!!

Link to comment
Share on other sites

  • 1 month later...

Hi

 

So I figured that this code in my header.tpl was interferring with all my other Facebook modules:

 

[color=#000000][font=arial, sans-serif][size=3]<html xmlns:og="[/size][/font][/color][url="http://ogp.me/ns#"]http://ogp.me/ns#[/url][color=#000000][font=arial, sans-serif][size=3]" xmlns:fb="[/size][/font][/color][url="http://www.facebook.com/2008/fbml"]http://www.facebook.com/2008/fbml[/url][color=#000000][font=arial, sans-serif][size=3]">[/size][/font][/color]

 

But this is what the opengraph module says must be added. How can I get Opengraph to work?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...