我正在(JQuery Mobile 和 Phonegap)的帮助下制作一个 Android( native 应用程序),我想在其中共享 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>
在这个应用程序中,我想分享文本区域中的数据,当我点击按钮时应该显示在 facebook 上
在不使用任何插件的情况下,如果我们可以,请帮助我,或者使用我们必须做的插件,然后告诉我如何逐步完成
最佳答案
通过 PhoneGap 在 Facebook 上分享数据
Use Child browser OR InAppbrowser plugin then add follwing code
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) {
});
}
关于android - 如何通过 phonegap 应用程序在 facebook 上共享数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19112146/