单击按钮后,使Facebook像按钮在墙上显示变量

时间:2011-09-02 03:08:42

标签: php facebook

我正在使用类似Facebook的按钮。它工作,显示我的域名和我的网站上的图像。但我想在墙上显示变量$submission。我怎样才能做到这一点?

Like按钮:

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>';

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($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>

1 个答案:

答案 0 :(得分:0)

我想你可能会过度思考这个

  • 让每个'提交'都有自己的网址(index.php?submissionid = X听起来正确)
  • 在此网址上有描述特定提交的开放图元标记
  • 将Like按钮(在您希望的任何页面上)指向该提交专用URL
  • Facebook将抓取元数据的提交特定网址,并在结果Feed故事中使用该网址