Facebook喜欢sencha建筑师的按钮

时间:2014-11-01 18:30:26

标签: facebook extjs sencha-touch-2 facebook-like sencha-architect

我有像facebook一样的按钮问题。 在Facebook开发者中,facebook为我们提供了3种不同的方法来在我们的应用程序中集成类似按钮。在这个例子中,我使用了所有3种方法。

我在sencha architect touch(Ext.Button)中创建了3个按钮。在我创建了一个基本函数后,我将传递给HTML按钮配置3个方法:

var me = this, htmlStrBase, htmlStr, htmlStrBase1, htmlStr1, htmlStrBase2, htmlStr2;

htmlStrBase = '<div class="fb-like" data-href="https://www.facebook.com/tecnitalia?ref=ts&fref=ts" data-layout="button" data-action="like" data-show-faces="false" data-share="false"></div>';
htmlStrBase1 = '<iframe src="//www.facebook.com/plugins/like.php?href=https://www.facebook.com/tecnitalia?ref=ts&fref=ts&amp;width&amp;layout=button&amp;action=like&amp;show_faces=false&amp;share=false&amp;height=35&amp;appId=838403862859130" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:35px;" allowTransparency="true"></iframe>';
htmlStrBase2 = '<html xmlns:fb="http://ogp.me/ns/fb#"><fb:like href="https://www.facebook.com/tecnitalia?ref=ts&fref=ts" layout="button" action="like" show_faces="false" share="false"></fb:like>';

me.getLikebutton().setHtml(htmlStrBase);
me.getLikebutton1().setHtml(htm

lStrBase1);
me.getLikebutton2().setHtml(htmlStrBase2);

htmlStrBase = '<div class="fb-like" data-href="https://www.facebook.com/tecnitalia?ref=ts&fref=ts" data-layout="button" data-action="like" data-show-faces="false" data-share="false"></div>'; htmlStrBase1 = '<iframe src="//www.facebook.com/plugins/like.php?href=https://www.facebook.com/tecnitalia?ref=ts&fref=ts&amp;width&amp;layout=button&amp;action=like&amp;show_faces=false&amp;share=false&amp;height=35&amp;appId=838403862859130" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:35px;" allowTransparency="true"></iframe>'; htmlStrBase2 = '<html xmlns:fb="http://ogp.me/ns/fb#"><fb:like href="https://www.facebook.com/tecnitalia?ref=ts&fref=ts" layout="button" action="like" show_faces="false" share="false"></fb:like>'; me.getLikebutton().setHtml(htmlStrBase); me.getLikebutton1().setHtml(htm lStrBase1); me.getLikebutton2().setHtml(htmlStrBase2);

自然首先我推出了FB.Init(用于桌面和应用程序):

if(Ext.os.is.Android || Ext.os.is.iOS) {

    FB.init({
        appId      : 'xxxxxxxxxxxxx',
        status     : true,
        nativeInterface: CDV.FB,
        useCachedDialog: false,
        xfbml      : true
    });

    //alert('dopo FB.init');
    FB.Event.subscribe('auth.statusChange', function(response) {
        //alert('status changed');
    });

(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/it_IT/sdk.js#xfbml=1&appId=XXXXXXXXX&version=v2.0";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

}
//Otherwise let's use the the web version
else
    {
        //Wait for sdk to load
        //alert('eseguo fbAsyncInit');
        window.fbAsyncInit = function() {

            FB.init({
                appId      : 'XXXXXXXXXX',
                status     : true,
                xfbml      : true
            });

            FB.Event.subscribe('auth.statusChange', function(response) {
                //alert('status changed');
            });
        };

        //alert(' after fbAsyncInit e now include SDK');
        //Include SDK

        (function(d, s, id){
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) {return;}
            js = d.createElement(s); js.id = id;
            js.src = "//connect.facebook.net/en_US/all.js";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));
    }

最终的结果是,在桌面上,它的功能完美但在我的Android应用程序还没有......我没有看到任何类似的按钮。

我说你最后一件事......如果我直接在html按钮配置中复制这三种方法中的一种,我可以在我的应用程序上看到类似按钮。但我无法直接在HTML配置按钮中复制此方法,因为每次用户登录我的应用程序时都需要更改Facebook地址。

有人可以帮助我,并且知道一种方法可以在我的应用程序中按下像按钮一样的音频吗? 谢谢 卡罗

嗨吉拉德。谢谢&#39; S。它的功能,但我有另一个问题。在Android之后喜欢登录它给我看一个空白页!!!!在桌面上没有mozilla或Firefox。 谢谢 卡罗

1 个答案:

答案 0 :(得分:0)

对我来说有一点不同的是在我的fb-root id面板已经到位后添加Facebook脚本。

在这里,我创建了一个带有底部工具栏的Container和另一个容器(fb-root),它有一个Sencha页面的Like按钮。

Ext.create('Ext.Container', {
    fullscreen: true,
    html : 'My Sencha touch panel',
    items: [
        {
            docked: 'top',
            xtype: 'titlebar',
            title: 'Sencha Touch',
        },{
            docked: 'bottom',
            xtype: 'toolbar',
            ui: 'light',
            items: [{
                xtype: 'container',
                id: 'fb-root',
                width: 50,
                height: 20
            }]
        }
    ],
    listeners: {
        initialize : function (container) {
            (function(d, s, id) {
                var js, fjs = d.getElementsByTagName(s)[0];
                if (d.getElementById(id)) return;
                js = d.createElement(s); js.id = id;
                js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0";
                fjs.parentNode.insertBefore(js, fjs);
            }(document, 'script', 'facebook-jssdk'));

            var html = '<div class="fb-like" data-href="https://www.facebook.com/senchainc" data-layout="button" data-action="like" data-show-faces="false" data-share="false"></div>';
            container.query('toolbar container')[0].setHtml(html);
        }
    }
});

小提琴:https://fiddle.sencha.com/#fiddle/cmm