亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Facebook如何檢查用戶是否喜歡頁面并顯示內容?

Facebook如何檢查用戶是否喜歡頁面并顯示內容?

一只甜甜圈 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

}


查看完整回答
反對 回復 2019-10-24
  • 3 回答
  • 0 關注
  • 554 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號