2011-12-24 89 views
1

我在Facebook中实现Graph API以从“https”站点以JSON方式检索数据。从http获取JSON链接

我用下面的代码

  FB.getLoginStatus(function(response) { 
       if (response.status === 'connected') { 
        var accessToken = response.authResponse.accessToken; 
        document.getElementById("statusCheck").innerHTML = accessToken; 
        $.getJSON('https://graph.facebook.com/me/friends?access_token=' . accessToken, 
         function(dataJSON){ 
         //The rest 
         });  
       }  
      }); 

此后未能我试图用$就没有数据类型的规范和解析与$ .parseJSON的数据,但没有信息在所有

检索

我的问题真的是双重的:我的JSON是检索问题还是协议是“https”的事实?如果不能在外部https协议上使用getJSON,我如何恢复Facebook朋友的哈希值?

回答

1

你的代码正在工作。只需在accesstoken之前使用+(加号)代替。(点)。

$.getJSON('https://graph.facebook.com/me/friends?access_token=' **+** accessToken, 
    function(dataJSON){ 
     console.log(dataJSON); 
}); 
+0

哈哈,哇,我觉得哑巴...谢谢。 – Vivek 2011-12-24 04:12:42

+0

:) np Vivek ..继续编码... – 2011-12-24 04:18:08