2013-09-26 39 views
-2

我想做一個網頁發佈狀態在Facebook中,但與FB網頁上的腳本我無法做到這一點。在Facebook的應用程序域

<!DOCTYPE html> 
<html> 
<body> 
<div id="fb-root"></div> 
<a href="#" onclick="return postToWall();">Post To Wall</a> 
<script src="//connect.facebook.net/en_US/all.js"></script> 
<script> 
    FB.init({ appId: 'XXXX', 
     status: true, 
     cookie: true, 
     xfbml: true, 
     oauth: true }); 

function postToWall() { 
    FB.login(function(response) { 
    console.log(response); 
     if (response.authResponse) { 
     FB.ui({ 
      method: 'feed', 
      name: 'Facebook Dialogs', 
      link: 'https://developers.facebook.com/docs/reference/dialogs/', 
      picture: 'http://fbrell.com/f8.jpg', 
      caption: 'Reference Documentation', 
      description: 'Dialogs provide a simple, consistent interface for applications to interface with users.' 
     }, 
     function(response) { 
      if (response && response.post_id) { 
      alert('Post was published.'); 
      } else { 
      alert('Post was not published.'); 
      } 
     }); 
    } else { 
    alert('User cancelled login or did not fully authorize.'); 
    } 
}, {scope: 'user_likes,offline_access,publish_stream'}); 
return false; 
} 
</script> 
</body> 
</html> 

當然,我使用我的應用程序的正確appId。我有沙箱模式的應用程序,因爲我還沒有任何東西,只是這個腳本。我的網頁將只有這個部分發布,沒有任何其他相關的Facebook。

我使用xampp在我的compunter中測試它。所以我想在facebook應用程序域我必須寫它,但我試過的一切(localhost,localhost/faceapp/...)失敗。例如,我得到這個:

Error 
App Domains: http://localhost/appFace should not contain protocol information. 

出現提示時,你可以寫你的用戶和密碼,但在下一個窗口告訴你的網頁在應用程序的配置和別的東西允許的。我用西班牙語閱讀,所以我不知道英文的確切句子。

我發現很多answet關於這個,但其中大多數是從api¨的舊版本(其中已經改變),其他人告訴使用localhost左右,我不能保存更改fb應用程序寫作。

+3

這個問題似乎是脫離主題,因爲它是關於閱讀和_understand_一個簡單的錯誤消息。 – CBroe

+0

爲什麼人們downvote的答案?如果你不喜歡,只要通過它 – Biribu

回答

1

在FB的應用程序設置中,放入應用程序域「localhost」,如果您使用的是使用FB登錄,則在網站URL中輸入http:// localhost /(不含空格),或者如果您創建了任何虛擬主機,輸入那個...

+0

謝謝你。有用。我想,當我將網頁上傳到我的服務器時,我必須對最後的網址做同樣的事情,不是嗎? – Biribu

+0

是的,你將不得不更新應用程序中的信息 –