General / Allgemeines > Programming

How to use Facebook Open Graph Protocol

(1/4) > >>

jeyjoo:
Hi,

I use version 1.7.6
My gallery is at www.jeyjoo.com/gallery/index.php
My detail page currently displays a like button count using Facebook OGP. when clicked the user likes the search page.
I would like to change this such that the user can like each individual URL.
To do this I need a way of automatically specifying:

1. The image url
2. The page to like URL (the current page url for each image)

and preferably:

3. title tag (using image title) e.g. <meta property="og:title" content="image of ....."/>
4. description tag using image description e.g.  <meta property="og:description" content="image description.............."/>

Any ideas,

Thanks,
Mike

bernd:
I can't access your site. AFAIK if you use the FBXML (or whatever the facebook freaks call their crap) like button and don't provide any URL it does take the current URL, doesn't it?

This PHP code would give you your current URL though:
$url = "http" . ((!empty($_SERVER['HTTPS'])) ? "s" : "") . "://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

And you can play around with that. I did a dirty hack using this as a basis in the functions.php to provide me with an absolute path to the thumbnail image which I include in the og:image meta tag.

jeyjoo:

--- Quote from: bernd on March 02, 2011, 08:48:55 PM ---$url = "http" . ((!empty($_SERVER['HTTPS'])) ? "s" : "") . "://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

--- End quote ---

Thanks. Tjhis is somehting like what I was looking for, though:
- where exactly do I place this code?
- how do I call it in the HTML e.g. is it [URL]?
- how do I create the img thumbnail call?

Much appreciated,
mike
p.s. my gallery is back up after a server issue yesterday!

uploadeur:
Same problem... Please someone help us. :)

jeyjoo:
I hate to delude, but I have not "done it"... everytime a user like's or tweets a page, they are actually liking the same page every time (my search page, which shows latest images posted). Consequently, a user can only click like on my site once.
Anyway, the required code is below:

EDIT HTML TAG TO INCLUDE FOLLOWING:
<html dir="ltr"  xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">


INSERT IN HEADER TAG
<meta property="og:title" content="5-a-day images @ Jeyjoo Gallery"/>
<meta property="og:description" content="Surf and sand... the best beaches in England"/>
<meta property="og:url" content="INSERT URL TO LINK TO"/>
<meta property="og:image" content="INSERT IMAGE TO SHOW ON FACEBOOK"/>
<meta property="og:type" content="company"/>
<meta property="fb:admins" content="INSERT YOUR FB ADMIN ID"/>

INSERT THIS BETWEEN BODY TAGS, WHERE YOU WANT THE LIKE BUTTON TO APPEAR
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:like href="INSERT HERE THE URL TO LIKE - THE LIKE COUNT WILL BE APPLIED TO THIS SPECIFIC URL" layout="button_count" show_faces="false" width="40" font="trebuchet ms"></fb:like>

Hope this helps,
Mike
www.jeyjoo.com

Navigation

[0] Message Index

[#] Next page

Go to full version