简体   繁体   English

通过phonegap访问我的Facebook应用程序

[英]Access to my Facebook application from phonegap

when I register my Facebook application I asked for Website URL. 当我注册我的Facebook应用程序时,我要求提供网站URL。 That means that only users from that URL can be access to Facebook API. 这意味着只有来自该URL的用户才能访问Facebook API。 But I don't need it. 但是我不需要。

I'm made a mobile application by phonegap, I used ionic (HTML5 mobile framework). 我通过phonegap制作了一个移动应用程序,我使用了ionic(HTML5移动框架)。

I made an initialize to Facebook SDK in my javascript files, and tried to access to the api. 我在JavaScript文件中对Facebook SDK进行了初始化,并尝试访问api。 Well it didn't work becuase the hostname on mobile application is '' (none, nothing, empty string), there is no hostname/URL parameter on mobile application. 好吧,因为移动应用程序上的主机名是'' (无,无,空字符串),所以没有用,移动应用程序上没有主机名/ URL参数。

When I tried it on my computer it worked when I put in Facebook application settings this website URL: http://localhost/ , and it's worked becuase i really was on localhost . 当我在计算机上进行尝试时,当我在Facebook应用程序设置中输入以下网站URL: http://localhost/ ,它便可以工作,因为我确实在localhost上,所以它可以工作。

How should I fix it, so I could access to my application from every URL and not only the URL I asked in the application settings? 我应该如何解决它,以便我可以从每个URL访问我的应用程序,而不仅仅是在应用程序设置中询问的URL?

Sample of my javascript code: (Written with angular.js) 我的JavaScript代码示例:(用angular.js编写)

$scope.loginFB = function() {
        Facebook.login(function(loginResponse) {
            if(loginResponse.status == 'connected') {
                $rootScope.$storage.local.userLoggedIn = true;
                Facebook.api('/me', function(facebookUser) {
                    $rootScope.$storage.local.currentUser = facebookUser;
                });
            }
        });
    };

看看github上的sociogram示例 ,该示例应用程序演示了如何在Angular / Ionic应用程序中与Facebook集成

If you have a mobile application, you should integrate with facebook mobile sdk for android and ios. 如果您拥有移动应用程序,则应与适用于android和ios的facebook mobile sdk集成。 See: 看到:

There are several cordova plugins that can help you with such integration (I am the author of one by the way). 有几个cordova插件可以帮助您进行这种集成(顺便说一句,我是一个的作者)。 You can search for these plugins at http://plugreg.com/search?q=facebook 您可以在http://plugreg.com/search?q=facebook搜索这些插件。

我已经成功使用了Facebook Connect插件,对于离子框架,您也可以尝试ngCordova Facebook

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM