分享數據
使用兒童瀏覽器或InAppbrowser插件再添加follwing代碼
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) {
});
}
來源
2013-10-01 09:30:24
Ved
解釋如何做到 –
1)首先你應該使用ChildBrowser插件爲Android或InAppBrowser插件添加到您的項目2)您應該從Facebook開發人員站點獲取客戶端ID 3)然後使用帶有參數的connectShare函數,它返回訪問令牌,然後將其傳遞給shareOnFaceBook(access_token)調用shareOnFaceBook中的postFBWall函數與參數。工作...! – Ved
postFBGraph函數不存在。 – Jronny