来自混合移动应用程序的Facebook上的帖子

问题描述:

我有一个混合移动应用程序(应该在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> 

感谢

我碰到了这一点。你的: document.location.protocol 这是假设拉入FB SDK实际上是“文件:///”,这是什么被馈送到该FB JS库的URL。 手动指定http://或https:// 这不适用于我在IOS上的safari webView上,所以我不得不使用AJAX手动点击端点。

+0

你有一个例子如何做到这一点?谢谢。 – 2013-12-15 18:55:56