Facebook share with dynamic text

user712027 picture user712027 · Aug 5, 2011 · Viewed 13.1k times · Source

I'm doing:

$fb = "http://www.facebook.com/sharer.php?t=".$title."&u=".$url;

That line is inside a while loop getting results from database. $url is always the same one but $title changes depending on the row.

Now I build the links and when I click them, they always show in my Wall the

<meta name="title" content=''>

text from my main page and not the $title text.

What can I do to fix this and share the text contained in $title?

Here the code I'm trying with og. After hitting the link the share text in my Wall is "Google" instead of what is in my variables:

<?php
$tt = "Some text in the meta";
    $url_p = "http://www.google.com";
        $url = urlencode($url_p);
        $text = "Text I want to show";
        $title = urlencode($text);
$fb = "http://www.facebook.com/sharer.php?t=".$title."&u=".$url;
?>
<meta property="og:title" content="<?php echo $tt; ?>"/>

<a href="<?php echo $fb; ?>">share link</a>