venerdì 4 novembre 2011

Socialize your typo3: typo3 and php for facebook integration

Maybe, like me, you have experienced mixed results when sharing your typo3 pages through facebook. THe social network platform tend to select the wrong image has thumbnail, some times the wrong texts too...

Looking at youtube i understand that there must be some way to control thoose things...

The final result of my search:

$GLOBALS ['TSFE'] -> additionalHeaderData ['100 '] ='<meta property="og:title" content="'.$tagg.'" />';
$GLOBALS ['TSFE'] -> additionalHeaderData ['101 '] ='<meta property="og:type" content="website" />';
$GLOBALS ['TSFE'] -> additionalHeaderData ['102 '] ='<meta property="og:url" content="http://www.urltoshare.org" />';
$GLOBALS ['TSFE'] -> additionalHeaderData ['103 '] ='<meta property="og:image" content="http://www.urltoshare.org/thumb/thumb_of_this_page.jpg" />';
$GLOBALS ['TSFE'] -> additionalHeaderData ['104 '] ='<meta property="og:site_name" content="Your site name" />';
$GLOBALS ['TSFE'] -> additionalHeaderData ['105 '] ='<meta property="fb:admins" content="123456789" />';
I insert this lines in a php script on a lumo net php object at the start of the page (i guess i may not work if you insert LATELY). As you can see, the first line has a $tagg variable i insert to example the options of get the contet of the  Facebook header datas from your (to say one) database... as i do!

Have a special look to the og:image line... it points to the right thumb image. You need a compliant thumb, i usually have my engine create 150x130 circa thumbs. See the specs on the facebook developers page.

The last muber sequence i guess you should get your own from facebook developers system!

You can see a sample of the final result here:

http://www.felixweb.it/galleria.php

You see my felixweb gallery of cat's picture's. Under every image you got a like button. Click one and you will share not the actual gallery page, nor the raw image, but a different page that contains a larger version of the image, the proper thumb and the php lumo that tells facebook the right thing to do to share your page.

Works really well for me!

Nessun commento:

Posta un commento