一只甜甜圈
2019-10-24 13:48:45
我正在嘗試創建一個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條經驗 獲得超6個贊
您需要編寫一些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
提交
取消