2013-09-26 40 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

是的,你将不得不更新应用程序中的信息 –