【发布时间】:2014-11-01 18:30:26
【问题描述】:
我在使用 facebook like 按钮时遇到问题。 在 facebook 开发者中,facebook 为我们提供了 3 种不同的方法来在我们的应用程序中集成点赞按钮。在本例中,我使用了所有 3 种方法。
我在 sencha architect touch (Ext.Button) 中创建了 3 个按钮。在我创建了一个基本函数后,我将 3 个方法传递给 HTML 按钮配置:
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&width&layout=button&action=like&show_faces=false&share=false&height=35&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 App 上还没有……我没有看到任何类似的按钮。
我说你最后一件事....如果我直接在 html 按钮配置中复制这 3 种方法之一,我可以在我的应用程序上看到类似按钮。但我不能直接在 HTML 配置按钮中复制此方法,因为每次用户登录我的应用程序时我都需要更改 facebook 地址。
有人可以帮助我并且知道一种方法可以在我的应用程序中动态地集成喜欢按钮吗? 谢谢你 卡罗
嗨,吉拉德。谢谢。它的功能,但我有另一个问题。在android中点赞登录后它显示一个空白页面!!!!不能在桌面上使用 Mozilla 或 Firefox。 谢谢 卡罗
【问题讨论】:
标签: facebook extjs sencha-touch-2 facebook-like sencha-architect