2011-12-19 108 views
0

我已經設置了一個簡單的應用程序在頁面標籤中運行。在授權使用該應用程序之後,僅針對基本信息,它會檢查用戶是否喜歡該頁面。如果他們不要求在繼續之前喜歡這個頁面 - 但是如果您在這一點上單擊了LIKE按鈕,它不會刷新頁面,因此我沒有看到我的應用程序中的更改。用戶被掛起,必須再次單擊頁面選項卡才能繼續,在這一點上它可以讓您進入。如果您在開始之前喜歡該頁面,則一切正常,並且LIKE按鈕正常刷新頁面。Facebook的頁面標籤 - 「LIKE」按鈕不能重新加載頁面

這是有原因嗎?或者我錯過了一個訣竅 - 我應該添加我自己的LIKE按鈕還是什麼?

幫助讚賞,因爲我真的很陌生的facebook應用程序。

編輯 - 我使用Asp.Net C#,如果這有所作爲。我發現很難找到任何好的文檔,所以我盡我所能將它拼湊在一起,所以請原諒這種混亂。這裏的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"> 
<head runat="server"> 
<title></title> 
<script src="http://connect.facebook.net/en_US/all.js" type="text/javascript"></script> 
<script type="text/javascript"> 
    FB.init({ 
     appId: '9999999999', 
     status: true, // check login status 
     cookie: true, // enable cookies to allow the server to access the session 
     xfbml: true // parse XFBML 
    }); 
</script> 
<script type="text/javascript"> 
    window.fbAsyncInit = function() { 
     FB.Canvas.setSize({ width: 520, height: 1300 }); 
    } 
    // Do things that will sometimes call sizeChangeCallback() 
    function sizeChangeCallback() { 
     FB.Canvas.setSize({ width: 520, height: 1300 }); 
    } 
</script> 
</head> 
<body style="width:520px;margin:0; padding:0; border:0;font-family:Arial;font-size:12px;"> 
<form id="form1" runat="server"> 
<div id="fb-root"> 
    <div id="intro" runat="server" style="width:520px;background-color:#FFFFFF;"> 
     Enter our competition<br /> 
     <br /> 
     <asp:Button ID="authorise" runat="server" Text="authorise" OnClick="Authorise_Click" /> 
    </div> 
    <div id="voting" runat="server" visible="false" style="background-color:#FFFFFF;width:520px;padding:0px"> 
     <div id="notliked" runat="server" visible="false"> 
      You must LIKE our page before you can enter the competition 
     </div> 
     <div id="questions" runat="server" visible="false"> 
      <div id="week1" runat="server" visible="false"> 
       Q1 Q2 Q3  
      </div> 
      <div id="week2" runat="server" visible="false"> 
       Q4 Q5 Q6 
      </div> 
      <div id="entereddiv" runat="server" visible="false"> 
       You have already entered this week's competition. 
      </div> 
     </div> 

    </div> 
    <div id="terms" runat="server" style="color:Black;font-size:11px;width:450px;"> 

    </div> 
</div> 

</form> 
<script type="text/javascript"> 

    window.fbAsyncInit = function() { 
     FB.init({ appId: '9999999999', status: true, cookie: true, xfbml: true, oauth: false }); 

     // If like button pressed, refresh page 
     FB.Event.subscribe('edge.create', function (response) { top.location = 'http://www.facebook.com/pages/MY_PAGE_NAME/PAGE_ID?sk=app_9999999999'; }); 

    }; 
    (function() { 
     var e = document.createElement('script'); e.async = true; 
     e.src = document.location.protocol + 
    '//connect.facebook.net/en_US/all.js'; 
     document.getElementById('fb-root').appendChild(e); 
    }()); 
</script> 

</body> 
</html> 
+0

它通常刷新頁面。嘗試它在其他地方,https://www.facebook.com/cocacola – 2011-12-19 12:35:19

+0

它刷新,但不授權應用程序後立即。如果我按照上面的解釋,重新啓動應用程序,單擊不同,然後使用LIKE按鈕它的工作,只是不在我需要它的地方。 – Dave 2011-12-19 12:57:56

回答

0

我想我實際上已經整理出來了 - 我沒有意識到我可以在沒有用戶授權的情況下獲得isLiked屬性。現在我已經切換了它,所以我先檢查signedrequest,然後在請求授權之前讓它們喜歡頁面。這讓我解決了這個問題。

我仍然認爲這是Facebook的一個錯誤,你不能這樣做,但對於這個解決方案將執行的項目。

0

你必須聽Facebook的JS API動作,並做一個回調刷新頁面。

嘗試將此代碼塊添加到您的網站的末尾。

<script type="text/javascript"> 

    window.fbAsyncInit = function() 
    { 
     FB.init({appId: '<appID>', status: true, cookie: true, xfbml: true, oauth: false }); 

     // If like button pressed, refresh page 
     FB.Event.subscribe('edge.create', function(response) { top.location = '<Page Address>'; }); 

    }; 
    (function() { 
     var e = document.createElement('script'); e.async = true; 
     e.src = document.location.protocol + 
     '//connect.facebook.net/en_US/all.js'; 
     document.getElementById('fb-root').appendChild(e); 
    }()); 
</script> 
+0

我會嘗試,謝謝 – Dave 2011-12-19 12:40:04

+0

這沒有奏效,我已經編輯添加html代碼,包括你的現在。 ID明顯改變 – Dave 2011-12-19 12:56:17

+0

你可以給你的粉絲頁面和應用程序標籤鏈接? – 2011-12-19 13:03:26

相關問題