Jump to content
tswitze

Facebook Open Graph Meta Tags

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)"/>

Share this post


Link to post
Share on other sites

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)"/>

Share this post


Link to post
Share on other sites

did you ever get this to work? i am trying to do the same thing..and get the cover image product thumb url and use it in the og:image meta tag in header.php.

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

Hi Jinxx

Thanks for your module. I just have one problem, the image will not show up for the product correctly. Can you please help? I have friendly url enabled on PS1.3.2

Thanks

Share this post


Link to post
Share on other sites

Hi Jinxx

im running 1.4.2.5, and the images is not showing up also. any fixed for that?

Share this post


Link to post
Share on other sites

Yes, there is something that is not working in creating the image URL,
it does this:

www.something.com/img/p/102--large.jpg

It's not getting the id_image for some reason.

Please help, this is a great module!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Hello,

Really good and light module!

 

Doesn't work with PS 1.4.3 since i update the shop ! :(

Share this post


Link to post
Share on other sites

my images have a new image path .../p/1/x/xxx.jpg

 

and this module link is to : .../p/xxx.jpg

 

i am confuse with this new way of stocking image ;)

 

thanks for you help !

Share this post


Link to post
Share on other sites

:(

 

I have not been managed to get this to work... when I click on the "like" button on a product, wrong image is being displayed att the wall on fb.

 

can someone tell step by step how to figured this out

 

best regards

Eddan

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

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!!

Share this post


Link to post
Share on other sites

Hi I tried this, it wasn't working and now suddenly my Facebook Like block & Facebook connect block isn't showing up properly. Any ideas why?

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More