在 Xcode 项目中实现 Facebook
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5383049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Implementing Facebook into Xcode Project
提问by PatrickGamboa
I am going to be implementing the facebook application into my project, but I've ran into some roadblocks. First I read about the link that developers.facebook.com has posted:
我将在我的项目中实施 facebook 应用程序,但我遇到了一些障碍。首先,我阅读了 developer.facebook.com 发布的链接:
I really don't know how to use the GitHub repository and add it to my app project, so I hope I can get some help with that,
我真的不知道如何使用 GitHub 存储库并将其添加到我的应用程序项目中,所以我希望我能得到一些帮助,
Next, while I was continuing the rest, I found something that I might need help on as well:
接下来,当我继续剩下的事情时,我发现了一些我可能也需要帮助的事情:
So that's all I have for now, I just need to get through this first part, then I can continue on, so I hope someone can help me get on through that first part, thanks
所以这就是我现在所拥有的,我只需要完成第一部分,然后我就可以继续,所以我希望有人能帮助我完成第一部分,谢谢
(sorry if I had to post the pictures, I just really need to be specific and I'm sometimes having trouble with reading tutorials)
(对不起,如果我不得不发布图片,我真的需要具体,我有时在阅读教程时遇到问题)
回答by dombesz
If you are not familiar with git you can download the sdk manually to your hard drive on this page: https://github.com/facebook/facebook-ios-sdk
click on downloads and select the preferred format.
如果您不熟悉 git,您可以在此页面上手动将 sdk 下载到您的硬盘:https://github.com/facebook/facebook-ios-sdk
单击下载并选择首选格式。
On the readme clearly states how to add the library to your own application:
自述文件清楚地说明了如何将库添加到您自己的应用程序中:
If you want to integrate Facebook with an existing application, then follow these steps:
Copy the Facebook SDK into your Xcode project:
- In Xcode, open the Facebook SDK by selecting File->Open...and selecting src/facebook-ios-sdk.xcodeproj.
- With your own application project open in Xcode, drag and drop the "FBConnect" folder from the Facebook SDK project into your application's project.
Include the FBConnect headers in your code:
#import "FBConnect/FBConnect.h"
You should now be able to compile your project successfully.
Register your application with Facebook:
- Create a new Facebook application at: http://www.facebook.com/developers/createapp.php. If you already have a related web application, you can use the same application ID.
- Set your application's name and picture. This is what users will see when they authorize your application.
如果要将 Facebook 与现有应用程序集成,请执行以下步骤:
将 Facebook SDK 复制到您的 Xcode 项目中:
- 在 Xcode 中,通过选择File-> Open...并选择 src/facebook-ios-sdk.xcodeproj打开 Facebook SDK 。
- 在 Xcode 中打开您自己的应用程序项目后,将“FBConnect”文件夹从 Facebook SDK 项目拖放到您的应用程序项目中。
在您的代码中包含 FBConnect 标头:
#import "FBConnect/FBConnect.h"
您现在应该能够成功编译您的项目。
在 Facebook 注册您的应用程序:
- 在http://www.facebook.com/developers/createapp.php创建一个新的 Facebook 应用程序。如果您已有相关的 Web 应用程序,则可以使用相同的应用程序 ID。
- 设置应用程序的名称和图片。这是用户在授权您的应用程序时将看到的内容。
You should have a file called yourProjectNameAppDelegate.h
and yourProjectNameAppDelegate.m
.
您应该有一个名为yourProjectNameAppDelegate.h
and的文件yourProjectNameAppDelegate.m
。
You have to put #import "FBConnect/FBConnect.h"
into yourProjectNameAppDelegate.h
.
And declare a variable in the header Facebook* facebok;
and also synthesize it.
你必须把#import "FBConnect/FBConnect.h"
成yourProjectNameAppDelegate.h
。并在头文件中声明一个变量Facebook* facebok;
并合成它。
Your yourProjectNameAppDelegate.m
contains a method called application:didFinishLaunchingWithOptions:
which should look like:
您yourProjectNameAppDelegate.m
包含一个调用的方法application:didFinishLaunchingWithOptions:
,该方法应如下所示:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
facebook = [[Facebook alloc] initWithAppId:@"YOUR_APP_ID"];
[facebook authorize:permissions delegate:self];
}
Also put in this file the other method.
也把另一种方法放在这个文件中。
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
return [facebook handleOpenUrl:url];
}
Also I suggest to learn a bit more about objective-c, because your problems are not related to the facebook library. You can find plenty of resources on the net. I suggest to look this iTunes university screencast.
另外我建议多了解一点objective-c,因为你的问题与facebook库无关。您可以在网络上找到大量资源。我建议看看这个 iTunes 大学截屏视频。
回答by MCannon
for github, go to http://help.github.com/they have loads of resources to help you out, but you pretty much just need to type git clone , and then find where it has put the repository.
对于 github,请访问http://help.github.com/他们有大量资源可以帮助您,但您几乎只需要键入 git clone ,然后找到它放置存储库的位置。
alternatively if you browse to the repo on the github website, you should be able to just click a download button.
或者,如果您浏览到 github 网站上的存储库,您应该只需单击下载按钮即可。
with the second bit, what do you need help with?
第二点,你需要什么帮助?
the app id will be from when you have set your application up in facebook.
应用程序 id 将来自您在 facebook 中设置应用程序时。