开发者

Making Facebook Like Button Display a Variable on Wall after Like Button is Clicked

I'm using a facebook like button. It works, showing my domain name and an image from my site. But I would like to also display the variable $submission on the Wall. How can I do that?

The Like Button:

echo '<div class="like2">';

echo '<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http://www.domain.com/directory/directory/fblike.php?submissionid='.$submissionid.'&submission='.$submission.'&uid='.$uid.'" send="true" layout="button_count" width="150" show_faces="false" font="arial"></fb:like>'; 

echo '</div>';

On www.domain.com/directory/directory/fblike.php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<div class="hslogo"><a href="http://www.domain.com/directory/"><img src="images/image.png" alt="Name" border="0"/></a></div>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>



<?php
session_start();

$submissionid = $_GET['submissionid'];
$uid = $_GET['uid'];

$submission = $_GET['submission'];




?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo urldecode($submission); ?></title>

<meta property="og:title" content="FB Like Page Test"/>

</head>
<body>


<?php



mysql_connect("server", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());


echo $submission;

$q = "INSERT INTO fblikes VALUES (NULL, '$submissionid', '$uid', NULL)";

$r = mysql_query(开发者_C百科$q);

if($r) //voting done
    {

//  echo "Success!";
    }
elseif(!$r) //voting failed
    {
//  echo "Failed!";
    }



header("Location: index.php?submission=".urlencode($submission)."&submissionid=".$submissionid"&uid=".$uid.");  


?>

</body>
</html>


I think you may be overthinking this

  • Make each 'submission' have its own URL (index.php?submissionid=X sounds right in your case)
  • On this URL have the open graph meta tags describing that particular submission
  • Point the Like button (on whatever page you wish) to that submission-specific URL
  • Facebook will scrape the submission-specific URL for the metadata and use that in the resulting feed story
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜