首先對於我的nooby問題抱歉,我幾乎到處檢查,但我沒有正確的答案。有很多文件和教程,但在發展中變化。但是,我的問題是,我有一個粉絲頁面,其中有一個與我的應用程序集成的Tab。Facebook的按鈕不起作用
我只想檢查會話用戶在這裏,他們已經喜歡前或如果他們已經喜歡我的網頁我想更新會話,並得到新的訪問令牌然後將其重定向到我流體畫布頁面(這是我的第二個問題btw。因爲登陸頁面在810px頁面之後,他們喜歡頁面刷新thmeself和它的固定區域再次開放。)
我必須把FB.login按鈕放到我的登陸頁面,還是在應用頁面加載時詢問用戶權限會更好。
我的文件夾模式是這樣的:
-appfolder
--tab - (landing page in fixed page)
--app - (app page in fluid canvas)
--css
--img
--js
--php-sdk
--index.php (check everything here and redirect in here with login attributes)
--config.php
--fbaccess.php
--fbin.php
--fbout.php
着陸頁代碼:
<?php
require 'php-sdk/facebook.php';
$app_id = 'xxx';
$app_secret = 'xxx';
// Set
$app_namespace = 'hangisienmeshur';
$app_url = 'https://apps.facebook.com/' . $app_namespace . '/';
$scope = 'email,publish_actions';
// Init the Facebook SDK
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
));
// Get the current user
$user = $facebook->getUser();
?>
<!DOCTYPE html>
<html xmlns:fb="http://ogp.me/ns/fb#" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tropicana Main</title>
<link href="css/normalize.css" rel="stylesheet" type="text/css" />
<link href="css/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="fb-root"></div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'xxx', // App ID
channelUrl : 'http://www.xxx.com/app/xx/channel.php', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional initialization code here
FB.Event.subscribe('edge.create',
function(response) {
window.location.href = 'https://apps.facebook.com/xxx/';
}
);
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
<div id="mainfoto">
<div id="fb_button" class="myClass rtl">
<fb:like href="http://www.facebook.com/xxx" width="100" layout="button_count" show_faces="false" send="false"></fb:like>
</div>
</div>
</body>
</html>
感謝您的回覆。我會嘗試一下,我會寫下結果。 –
感謝您的迴應,但它不工作,因爲有APP_ID和其他控制器在這裏失蹤。我不能用這個函數解析我的數據。不工作。 –