2012-07-17 112 views
-1

我正在嘗試facebok api。 爲此,我創建了一個應用程序密鑰。 並寫了一個小程序。安裝apache並執行該HTML文件。 Facebook的標誌來了,但我無法從該程序中獲取任何值。 如果我在Facebook控制檯上執行相同的程序,它的工作原理和給出的值。facebook api打電話離線

是不是可以在連接到互聯網的本地機器上使用Facebook API,但是在私有IP中。我不想直接在我的服務器上工作。希望我的機器上離線測試一些東西,比部署code..is它不可能>

有沒有更好的辦法了Facebook的API使用Java API來打印frdslist

<html> 
<head> 
    <title>My Test Facebook Login Page</title> 
</head> 
<body> 

    <div id="fb-root"></div> 
    <script> 
    window.fbAsyncInit = function() { 
     FB.init({ 
     appId  : 'xxxxx', // App ID 
     channelUrl : 'sample.com/backup', // Channel File 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     xfbml  : true // parse XFBML 
     }); 
    };     
    // Load the SDK Asynchronously 
    (function(d){ 
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; 
     if (d.getElementById(id)) {return;} 
     js = d.createElement('script'); js.id = id; js.async = true; 
     js.src = "//connect.facebook.net/en_US/all.js";   
     ref.parentNode.insertBefore(js, ref); 
    }(document)); 


    FB.api('/me', function(response) { 
alert("Name: "+ response.name + "\nFirst name: "+ response.first_name + "ID: "+response.id); 
var img_link = "http://graph.facebook.com/"+response.id+"/picture" 

}) ;

 FB.api('/me/friends', { fields: 'name,id,location,birthday' }, function(result) { 

}) 


    </script> 


    <div class="fb-login-button" >Login with Facebook</div> 


</body> 

+0

如果Facebook可以從本地機器訪問,那麼它應該可以正常工作。你可以發佈一些代碼嗎? – 2012-07-17 07:22:51

+0

你能否讓我知道是否還有其他事情需要完成以在本地運行。 – 2012-07-18 06:42:04

回答

0

添加 「read_friendlist」 權限。

+0

感謝subir回覆。 – 2012-07-22 06:31:34

+0

另外,我可以在運行apache的本地機器上運行上述程序。我想在部署到實時網絡之前運行它。 o對於我的基本測試,我嘗試在本地運行,但不起作用。但在Facebook控制檯它的作品 – 2012-07-22 06:32:55