Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook share with dynamic text

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>
like image 380
user712027 Avatar asked Aug 05 '11 07:08

user712027


People also ask

How do I customize my share button on Facebook?

Head over to Meta's documentation and use their button configurator to get the code for a Like and Share Button, or a Share Button. Once you select the options for your custom button, click the Get Code button and a new dialog box will appear with two different scripts.


2 Answers

You can use this one, is much better and you don´t have to use metatags:

http://www.facebook.com/sharer/sharer.php?s=100&p%5Btitle%5D=Title&p%5Bsummary%5D=Test%20Summary.&p%5Burl%5D=http://www.ideocentro.com/&p%5Bimages%5D%5B0%5D=https://static.e-junkie.com/sslpic/64332.ed95f53b41bc4885dd86e2b485f08a3b.jpg

like image 193
Sebastián Horvath Avatar answered Sep 22 '22 15:09

Sebastián Horvath


This isn't currently possible via the sharer API if your url is 'always the same' and please include any relevant code since I cannot see how your, 'ine is inside a while loop getting results from database'.

like image 37
live87 Avatar answered Sep 25 '22 15:09

live87