android - 如何通过 phonegap 应用程序在 facebook 上共享数据

标签 android facebook jquery-mobile cordova

我正在(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/

相关文章:

facebook - 有什么方法可以验证 Facebook 集成的 Open Graph 协议(protocol)元标记吗?

javascript - Facebook Graph API - 让 friend 参加事件?

javascript - 如何向 JQuery Mobile Panel 添加链接列表?

javascript - jqm 改变可折叠的位置

android - 在 ListView 中绑定(bind) fragment

android setBackgroundColor 在运行时和其他一般混淆有帮助吗?

android - 关于多进程情况下的android Sqlite安全

facebook - 无法访问应用程序命名空间

javascript - 将数据从一个页面传输到另一个 jQuery Mobile

Android-hdpi屏幕下背景变长