2012-09-23 44 views
3

我想知道我是否写过我的频道网址。在JavaScript SDK参考https://developers.facebook.com/docs/reference/javascript/;在频道文件中的部分说:想知道我是否为facebook javascript sdk编写了频道url。

的channelUrl必须是一个完全合格的URL上 您包括SDK匹配的页面。换句话说,如果您的网站使用www来提供服务,并且您在网页上修改了 document.domain,则频道文件域 必须包含www,您必须在channel.html文件中制作相同的document.domain 更改。该协议还必须匹配 。如果您的页面通过https提供,则您的channelUrl也必须为 https。请记得使用脚本src的匹配协议作为 。

这是我的Javascript SDK页: 注:我放在同一文件夹中channel.html文件作为我的index.php文件,我不知道这是正确的要么。

<body> 
     <div id="fb-root"></div> 
<script src="http://connect.facebook.net/en_US/all.js"></script> 

<script> 
    window.fbAsyncInit = function() { 
    FB.init({ 
     appId  : '278374582262040', // App ID 
     **channelUrl : 'localhost/controllers/index.php/channel.html', // Channel File** 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     xfbml  : true // parse XFBML 
    }); 

//the rest of the sdk code 

回答

4
channelUrl : 'localhost/controllers/index.php/channel.html' 

你提出任何协议存在一样 - 这意味着,浏览器会从一个叫localhost/controllers/当前目录下的目录请求文件。

您应该提供从//localhost/开始的地址 - 这可以让浏览器根据用于检索执行脚本的上下文中的文档的协议来决定使用哪种协议 - 也就是说,您的安全方面无论您的网页是使用HTTP还是HTTPS浏览。

“请记住,使用匹配的协议脚本SRC为好。”

<script src="http://connect.facebook.net/en_US/all.js"></script> 

这适用于JS SDK的嵌入以及 - 使用//connect.facebook.net/…