我有一个 canvas facebook 应用程序,它有一个网页和一个指定的移动页面。 该网页运行良好,并且在使用控制台将浏览器模拟到移动设备时一切正常。
但是,当我尝试从 Facebook 移动应用程序运行该应用程序时, Canvas 应用程序会加载(这是正确的),但它不会登录。
我正在使用 FB.login 函数。
login: function () {
var deferred = $q.defer();
FB.login(function (response) {
if (!response || response.error) {
deferred.reject('Error occured');
} else {
deferred.resolve(response);
}
}, {
scope: 'email, user_friends'
});
return deferred.promise;
},
在设置 > 高级 - 我有: 客户端 OAuth 登录、Web OAuth 登录、嵌入式浏览器 OAuth 登录、有效的 OAuth 重定向 URI 和正确填写的设备登录。
但仍然来自 Facebook 移动应用程序, Canvas 应用程序不会执行登录。
我一整天都在努力让它工作。 而且我无法在任何地方找到解决方案。 我也无法调试移动 facebook 应用程序。
有什么想法可以解决这个问题吗?
编辑
还查看了我的节点服务器日志,我发现甚至没有调用 FB.login。
编辑 2
我最终用 getLoginStatus 替换了登录名,这对我来说没有问题,因为它是一个 facebook canvas 应用程序......但问题仍然是如何登录。
编辑 3 11/26/2015
好吧,getLoginStatus 并没有完全解决我的问题,因为它实际上并没有让用户登录,所以对于 Canvas 游戏,如果您需要权限,您可能需要在第一次进入时登录...我的解决方案是添加登录如果 getLoginStatus 像这样返回 not_autorized:
/**
* [getLoginStatus get the FB login status]
* @return {[type]} [description]
*/
getLoginStatus: function () {
var deferred = $q.defer();
FB.getLoginStatus(function (response) {
if (response.status === 'connected') {
deferred.resolve(response);
} else if (response.status === 'not_authorized') {
_fbFactory.login().then(function (fbLoginResponse) {
deferred.resolve(fbLoginResponse);
});
} else {
deferred.reject('Error occured');
}
});
return deferred.promise;
},
但等等,还有更多... FB.login 函数在移动 Canvas 游戏上无法正常工作(不确定它是否未触发或浏览器记录弹出窗口或两者)。无论如何你需要通过按钮主动调用它...所以对于移动 Canvas 游戏我必须添加一个开始播放按钮然后登录才有效..
编辑 4(最终)
最终我注意到 FB.login() 不会被触发,除非它是触发它的外部事件,所以我不得不对移动 Canvas 进行更改,如果 getLoginStatus 没有返回连接,那么我会显示一个登录按钮登录...其余保持不变。 我为移动设备所做的与接受的答案相似,只是为了满足我的需要...
我希望这对我以外的人有帮助...
最佳答案
确保您使用用户触发的事件调用 FB.login(),例如单击按钮,因为浏览器可以阻止直接调用的潜在不安全/危险的 javascript。这为最终用户提供了额外的安全层。有两种创建登录按钮的方法:
生成的登录按钮看起来类似于:
<fb:login-button scope="public_profile,email" onlogin="checkLoginState();"> </fb:login-button>
<button onclick="FB.init()">Login</button>
来自 Facebook 开发者网站的注释:
As noted in the reference docs for this function, it results in a popup window showing the Login dialog, and therefore should only be invoked as a result of someone clicking an HTML button (so that the popup isn't blocked by browsers).
https://developers.facebook.com/docs/facebook-login/web
此外,FB.getLoginStatus 是正确的登录第一步,用于检查您的用户是否已登录 facebook 和您的应用。
There are a few steps that you will need to follow to integrate Facebook Login into your web application, most of which are included in the quickstart example at the top of this page. At a high level those are:
- Checking the login status to see if someone's already logged into your app. During this step, you also should check to see if someone has previously logged into your app, but is not currently logged in.
- If they are not logged in, invoke the login dialog and ask for a set of data permissions.
- Verify their identity.
- Store the resulting access token.
- Make API calls.
- Log out.
我看到您的游戏不再需要登录,但也许其他人会发现这个答案很有用。 :)
关于javascript - Facebook Canvas,无法在移动设备上从 Facebook 登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33596512/
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我的代码目前看起来像这样numbers=[1,2,3,4,5]defpop_threepop=[]3.times{pop有没有办法在一行中完成pop_three方法中的内容?我基本上想做类似numbers.slice(0,3)的事情,但要删除切片中的数组项。嗯...嗯,我想我刚刚意识到我可以试试slice! 最佳答案 是numbers.pop(3)或者numbers.shift(3)如果你想要另一边。 关于ruby-多次弹出/移动ruby数组,我们在StackOverflow上找到一
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e
我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳
我在pry中定义了一个函数:to_s,但我无法调用它。这个方法去哪里了,怎么调用?pry(main)>defto_spry(main)*'hello'pry(main)*endpry(main)>to_s=>"main"我的ruby版本是2.1.2看了一些答案和搜索后,我认为我得到了正确的答案:这个方法用在什么地方?在irb或pry中定义方法时,会转到Object.instance_methods[1]pry(main)>defto_s[1]pry(main)*'hello'[1]pry(main)*end=>:to_s[2]pry(main)>defhello[2]pry(main)
我使用的是Firefox版本36.0.1和Selenium-Webdrivergem版本2.45.0。我能够创建Firefox实例,但无法使用脚本继续进行进一步的操作无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055)错误。有人能帮帮我吗? 最佳答案 我遇到了同样的问题。降级到firefoxv33后一切正常。您可以找到旧版本here 关于ruby-无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055),我们在StackOverflow上找到一个类
当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub
我有一个rubyonrails应用程序。我按照facebook的说明添加了一个像素。但是,要跟踪转化,Facebook要求您将页面置于达到预期结果时出现的转化中。即,如果我想显示客户已注册,我会将您注册后转到的页面作为成功对象进行跟踪。我的问题是,当客户注册时,在我的应用程序中没有登陆页面。该应用程序将用户带回主页。它在主页上显示了一条消息,所以我想看看是否有一种方法可以跟踪来自Controller操作而不是实际页面的转化。我需要计数的Action没有页面,它们是ControllerAction。是否有任何人都知道的关于如何执行此操作的gem、文档或最佳实践?这是进入布局文件的像素