2013-04-24 61 views
0

我有一個混合移動應用程序(應該在android和ios中工作)。我需要在我的應用程序中發佈在Facebook牆上。請注意它的hybrib應用程序,所以我不應該使用任何java或c代碼。來自混合移動應用程序的Facebook上的帖子

我嘗試了以下方法,它在模擬器中工作,但不是在實際設備中。請幫幫我。

<script> 
window.fbAsyncInit = function() { 
FB.init({ 
appId : ' my appID', 
status : true, // check login status 
cookie : true, // enable cookies to allow the server to access the session 
xfbml : true // parse XFBML 
}); 
}; 

(function() { 
var e = document.createElement('script'); 
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; 
e.async = true; 
document.getElementById('fb-root').appendChild(e); 
}()); 
</script> 


     <script type="text/javascript"> 
$(document).ready(function(){ 
$('#share_button').live('click', function(e){ 
e.preventDefault(); 
FB.ui(
{ 
method: 'feed', 
name: 'HyperArts Blog', 
link: 'http://hyperarts.com/blog', 
picture: 'http://www.hyperarts.com/_img/TabPress-LOGO-Home.png', 
caption: 'I love HyperArts tutorials', 
description: 'The HyperArts Blog provides tutorials for all things Facebook', 
message: '' 
}); 
}); 
}); 
</script> 

感謝

回答

1

我碰到了這一點。你的: document.location.protocol 這是假設拉入FB SDK實際上是「文件:///」,這是什麼被饋送到該FB JS庫的URL。 手動指定http://或https:// 這不適用於我在IOS上的safari webView上,所以我不得不使用AJAX手動點擊端點。

+0

你有一個例子如何做到這一點?謝謝。 – 2013-12-15 18:55:56

相關問題