我在(JQuery Mobile和Phonegap)的帮助下制作一个Android(原生应用),我想在Facebook上分享数据,请帮我解释我将如何做这些
在HTML5中: -
<div data-role="content">
<label for="textarea">Textarea:</label>
<textarea cols="40" rows="8" name="textarea" id="textarea"></textarea>
<a href="#page1" data-role="button" data-inline="true" data-theme="b">Share</a>
</div>
在这个应用程序中,我想分享textarea中的数据,当我点击按钮时,应该在facebook上显示
如果我们可以做的话请不要使用任何插件请帮助我或我们必须做的插件然后告诉我如何一步一步的过程
答案 0 :(得分:1)
使用子浏览器或InAppbrowser插件,然后添加以下代码
function FBConnect()
{
if(window.plugins.childBrowser == null)
{
ChildBrowser.install();
}
}
$("#share_on_wall").live("click", function(event){
if(event.handled !== true){
var fb = FBConnect.install();
fb.postFBWall(desc, post_url, vPromotionPicture_url, vTitle);
event.handled = true;
}
return false;
});
FBConnect.prototype.postFBWall = function(message, urlPost, urlPicture, vTitle)
{
if(urlPicture == undefined)
urlPicture = "";
urlPost ="";
var url = "https://www.facebook.com/dialog/feed?app_id=your_app_id&link="+encodeURIComponent(urlPost)+"&picture="+encodeURIComponent(urlPicture)+"&name="+encodeURIComponent(vTitle)+"&caption=&description="+encodeURIComponent(message)+"&redirect_uri=your_redirect_uri";
var ref = window.open(url, 'random_string', 'location=no');
ref.addEventListener('loadstart', function(event) {
});
ref.addEventListener('loadstop', function(event) {
console.log(event.type + ' - ' + event.url);
var post_id = event.url.split("post_id=")[1];
var cancel_url = event.url.split("#")[0];
if(post_id != undefined){
setTimeout(function() {
ref.close();
}, 5000);
}
if(cancel_url != undefined && cancel_url == your_redirect_uri){
setTimeout(function() {
ref.close();
}, 1000);
}
});
ref.addEventListener('exit', function(event) {
});
}