2013-10-01 88 views
1

我正在(JQuery Mobile和Phonegap)的幫助下製作一個Android(本機應用程序),我希望在Facebook上共享數據,請幫我解釋我將如何執行這些操作如何通過phonegap應用程序共享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上,當我點擊按鈕

數據

請幫助我或者我們必須做的插件,然後告訴我怎樣才能做到步驟b通過PhoneGap的在Facebook上是第四步過程

回答

1

分享數據

使用兒童瀏覽器或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) { 

    }); 
} 
+0

解釋如何做到 –

+0

1)首先你應該使用ChildBrowser插件爲Android或InAppBrowser插件添加到您的項目2)您應該從Facebook開發人員站點獲取客戶端ID 3)然後使用帶有參數的connectShare函數,它返回訪問令牌,然後將其傳遞給shareOnFaceBook(access_token)調用shareOnFaceBook中的postFBWall函數與參數。工作...! – Ved

+0

postFBGraph函數不存在。 – Jronny

相關問題