Tuesday, December 2, 2008

Facebook: can't next fb:name inside of a meta tag of an fb:share-button

This won't work:

<fb:share-button class="meta">

<meta name="medium" content="blog"/>

<meta name="title" content="<fb:name uid=<?php echo $userid ?> useyou=false /> found this great video"/>

<meta name="video_type" content="application/x-shockwave-flash"/>

<meta name="video_height" content="345"/>

<meta name="video_width" content="473"/>

<meta name="description" content="Cleaning the coastline"/>

<link rel="image_src" href="http://mysite.com/myimage.jpg"/>

<link rel="video_src" href="http://mysite.com/myimage.flv"/>

<link rel="target_url" href="http://mysite.com"/>

</fb:share-button>


Now you are probably wondering why I wouldn't just set the name var in php and print that instead but this was being used as the return call from ajax and I wanted to try and use the fb:name tag just like any other fb tag. But it doesn't work. So it appears that "some" fb tags can be nested but not this one (or just not in this way).

As a workaround I sent the name along with the other params in the ajax call and just built the whole string on the server instead:


<?php

$username = $_GET['username'];

$itemId = $_GET['itemId'];

$itemDescription = $_GET['itemDescription'];

$itemURL = $_GET['itemURL'];

$itemImage = $_GET['itemImage'];

$itemType = $_GET['itemType'];


if($itemType=='video'){



echo '<fb:share-button class="meta"> <meta name="medium" content="blog"/> <meta name="title" content="' . $username . ' found this great video on Baha\'i Explorer"/><meta name="video_type" content="application/x-shockwave-flash"/><meta name="video_height" content="345"/> <meta name="video_width" content="473"/> <meta name="description" content="'. $itemTitle . '"/> <link rel="image_src" href="http://i3.ytimg.com/vi/'. $itemId . '/default.jpg"/> <link rel="video_src" href="http://www.youtube.com/v/' . $itemId . '&hl=en&fs=1"/> <link rel="target_url" href="' . $itemURL .'"/> </fb:share-button>';

}

 

?>

No comments: