简体   繁体   English

ShareKit与Facebook联系

[英]ShareKit Connect with Facebook

I have an application where users need to login/create an account in order to use it. 我有一个应用程序,用户需要登录/创建一个帐户才能使用它。 I am trying to implement Connect with Facebook through ShareKit 2.0. 我正在尝试通过ShareKit 2.0实现与Facebook的连接。 Do you know if this is possible and can you please point me in the right direction? 你知道这是否可能,请你指出正确的方向吗? Thanks 谢谢

Yes you can use Facebook as a point of login to any app. 是的,您可以使用Facebook作为登录任何应用程序的点。 Before doing that you need to register your app in Facebook Developers page. 在此之前,您需要在Facebook Developers页面注册您的应用程序。 More info here : http://developers.facebook.com/ 更多信息: http//developers.facebook.com/

After creating an App entry in Facebook, save the App id for setting configuration in Sharekit. 在Facebook中创建应用程序条目后,保存App ID以在Sharekit中设置配置。

Sharekit uses a defaultConfiguration file(where all configurations related to your app resides) and it recommends to override that class for setting your app-specific defines. Sharekit使用defaultConfiguration文件(其中包含与您的应用相关的所有配置),并建议覆盖该类以设置特定于应用程序的定义。

Link: https://github.com/ShareKit/ShareKit/wiki/Configuration 链接: https//github.com/ShareKit/ShareKit/wiki/Configuration

Once after Subclassing the configuation file, add your Facebook App id there. 在对子配置文件进行子类化之后,在那里添加您的Facebook App ID。 (I guess secret key is not required as its by default disabled after creating an Facebook app). (我猜秘密密钥不是必需的,因为在创建Facebook应用程序后默认禁用密码)。

Once you login to Facebook via Sharekit,you will get the token(it will be saved in the NSUserdefaults with a key - @"kSHKFacebookAccessToken" ) and if you need more data from facebook, you can subclass SHKFacebook class and access data from Facebook with the access token. 一旦您通过Sharekit登录Facebook,您将获得令牌(它将使用密钥保存在NSUserdefaults中 - @“kSHKFacebookAccessToken”)并且如果您需要来自Facebook的更多数据,您可以继承SHKFacebook类并使用Facebook访问数据访问令牌。

For logging in via Sharekit to Facebook,You need to do this. 要通过Sharekit登录到Facebook,您需要这样做。

       SHKSharer *service = [[[SHKFacebook alloc] init] autorelease];
        if(![service authorize]) //This will prompt for login if token was not saved or if it got expired. 
        {
              service.shareDelegate = self; //implement the delegate so that once after login you will get to know when to fetch token.
        }
        else
        {
              //Directly access the token with the key in NSUserdefaults and use this.
        }

Hope this helps! 希望这可以帮助!

Update: If you want to use Sharekit only for this option(for FB Log-in), I would recommend to use Facebook SDK instead. 更新:如果您只想将Sharekit用于此选项(对于FB登录),我建议使用Facebook SDK。 Sharekit makes life easier for sharing among different Sharing services! Sharekit使得在不同的共享服务之间共享更加轻松!

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

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