-3
我想創建一個PHP腳本來檢查用戶是否喜歡頁面。如果用戶喜歡這個頁面,那麼他會被重定向到另一個URL,如果不是這個用戶被要求喜歡這個頁面,那麼這個用戶可以喜歡這個Facebook like按鈕。如何檢查用戶是否喜歡Facebook頁面,如果是重定向到其他頁面?
請問這怎麼辦?我設法弄到了這個腳本並且遇到了錯誤。請幫忙嗎?如果您的應用程序運行在Facebook內部的畫布應用程序和網頁標籤應用
感謝
<!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" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Facebook "If-Like" Application | ThreeDots</title>
</head>
<body>
<?php
include_once("facebook.php");
$fbAppArray = array(
'appId' => 'YOUR_APPLICATION_ID',
'secert' => 'YOUR_APPLICATION_SECRET',
'cookie' => true
);
$fbAppObj = new Facebook($fbAppArray);
$signedRequest = $fbAppObj->getSignedRequest();
function parsePageSignedRequest()
{
if(isset($_REQUEST['signed_request']))
{
$encoded_sig = null;
$payload = null;
list($encoded_sig, $payload) = explode('.', $_REQUEST['signed_request'], 2);
$sig = base64_decode(strtr($encoded_sig, '-_', '+/'));
$data = json_decode(base64_decode(strtr($payload, '-_', '+/'), true));
return $data;
}
return false;
}
if($signedRequest = parsePageSignedRequest())
{
if($signedRequest->page->liked)
{
// What to show the user if he liked the application...
}else{
// Please like the application so you will be able to see the contents...
}
}
?>
</body>
</html>
這是後者...該應用程序不在Facebook內運行:-)我該如何處理它然後請? –
_「我該怎麼處理它然後請?」_ - 用** RTFM **關於我剛纔提到的主題,_please_ ... – CBroe