2012-12-11 40 views
0

我想使用JavaScript FB.api發佈圖像到用戶牆。圖像是從一個java servlet動態生成的,但是由於圖像生成之前的異步行爲,它會將控件傳遞到塊下面以將圖像發佈到Facebook部分。 我想要麼臉譜圖API調用後使用servlet圖像

  1. 我該如何使fb.api發佈到Facebook從servlet調用?
  2. 如何處理這種行爲,以便在圖像生成之前控制權不會通過下方?

note servlet正在工作文件並生成圖像。

var imgURL="http://xxx.xxx.xxx.xxx:8084/myapps/app1?monthly="+monthly+"&recent="+recent+"&likes="+likes; 

//var imgURL="http://xxx.2xx.xx6.1x8:8084/WebApplication6/image"; 
alert('image'); 
//var imgURL="https://graph.facebook.com/100000329585395/picture"; 
var img = document.createElement('img'); 
img.src =imgURL; 
document.body.appendChild(img); 


FB.api('/me/photos', 'post', { 
message:'image', 
url:imgURL   
         }, function(response){ 
          alert('here'); 

if (!response || response.error) { 
    alert('Error occured'+response.error); 
} else { 
    var postId = response.id; 
    alert(postId);} 


}); 

回答

1

檢查RESTFB Api是Java API。你可以使用它來代替Javascript API。