我正在尝试创建一个Facebook iFrame应用。该应用程序应首先显示图像,如果用户喜欢该页面,则可以访问某些内容。我使用RoR,因此无法使用Facebook PhP SDK。当用户不喜欢该页面时,这是我的iFrame HTML:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><link rel="stylesheet" type="text/css" href="style.css" /><style type="text/css">body {width:520px;margin:0; padding:0; border:0;font-family: verdana;background:url(repeat.png) repeat;margin-bottom:10px;}p, h1 {width:450px; margin-left:50px; color:#FFF;}p {font-size:11px;}</style><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" /></head><body><div id="container"><img src="welcome.png" alt="Frontimg"></div>并且,如果用户喜欢该页面:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><link rel="stylesheet" type="text/css" href="style.css" /><style type="text/css">body {width:520px;margin:0; padding:0; border:0;font-family: verdana;background:url(repeat.png) repeat;margin-bottom:10px;}p, h1 {width:450px; margin-left:50px; color:#FFF;}p {font-size:11px;}</style><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" /></head><body><div id="container"><img src="member.png" alt="Frontimg"><p>You liked this page</p>
3 回答
ibeautiful
TA贡献1993条经验 获得超5个赞
您需要编写一些PHP代码。当用户第一次单击选项卡时,您可以检查他是否喜欢该页面。下面是示例代码
include_once("facebook.php");
// Create our Application instance.
$facebook = new Facebook(array(
'appId' => FACEBOOK_APP_ID,
'secret' => FACEBOOK_SECRET,
'cookie' => true,
));
$signed_request = $facebook->getSignedRequest();
// Return you the Page like status
$like_status = $signed_request["page"]["liked"];
if($like_status)
{
echo 'User Liked the page';
// Place some content you wanna show to user
}else{
echo 'User do not liked the page';
// Place some content that encourage user to like the page
}
添加回答
举报
0/150
提交
取消