简体   繁体   English

FBSDKGraphRequest使用未声明的标识符

[英]FBSDKGraphRequest use of undeclared identifier

Though I have imported FacebookSDK like: #import <FacebookSDK/FacebookSDK.h> , but it says: use of undeclared identifier 'FBSDKGraphRequest'. 尽管我已经导入了FacebookSDK,例如: #import <FacebookSDK/FacebookSDK.h> ,但是它说:使用了未声明的标识符'FBSDKGraphRequest'。

The code I wrote is simple: 我写的代码很简单:

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                                      initWithGraphPath:@"/{user-id}/albums"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                              id result,
                                              NSError *error) {
            // Handle the result
        }];

Let me know what may I be missing? 让我知道我可能会丢失什么?

Since version 4.X Facebook has split the SDK in 3 parts: 从版本4.X开始,Facebook将SDK分为3部分:

Per documentation : 每个文档

The SDK is now composed of three frameworks, FBSDKCoreKit , FBSDKLoginKit , and FBSDKShareKit . 该SDK现在由三个框架FBSDKCoreKitFBSDKLoginKitFBSDKShareKit

FBSDKCoreKit provides core SDK functionality such as Graph API Requests, access tokens, and App Insights. FBSDKCoreKit提供了核心的SDK功能,例如Graph API请求,访问令牌和App Insights。

FBSDKLoginKit provides functionality to log people in, and only requires FBSDKCoreKit . FBSDKLoginKit提供了用于登录人员的功能,只需要FBSDKCoreKit

FBSDKShareKit provides functionality to share, and only requires FBSDKCoreKit . FBSDKShareKit提供了共享功能,只需要FBSDKCoreKit

As for your question: 至于你的问题:

Requests - FBSDKGraphRequest and FBSDKGraphRequestConnection are in FBSDKCoreKit and provide helpers to access the Graph API 请求FBSDKGraphRequestFBSDKGraphRequestConnectionFBSDKCoreKit并提供帮助程序来访问Graph API

So basically you need to import FBSDKCoreKit in your file: 因此,基本上,您需要在文件中导入FBSDKCoreKit

#import <FBSDKCoreKit/FBSDKCoreKit.h>

For login into Facebook using new SDK 4.1 You have to add the FBSDKLoginkit and FBSDKCoreKit Frameworks in your project. 要使用新的SDK 4.1登录到Facebook,您必须在项目中添加FBSDKLoginkit和FBSDKCoreKit框架。

Then import the below header files into your ViewController: 然后将以下头文件导入到ViewController中:

#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>

For more information you can refer the facebook official document here or you can refer these answers 有关更多信息,您可以在此处参考facebook官方文档,也可以参考以下答案

  1. First answer 第一个答案
  2. Second answer 第二个答案

Eventhough facebook official document is best. 尽管facebook官方文件是最好的。

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

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