commit | author | age
|
2e29a3
|
1 |
/* |
L |
2 |
* Copyright (c) Meta Platforms, Inc. and affiliates. |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* This source code is licensed under the license found in the |
|
6 |
* LICENSE file in the root directory of this source tree. |
|
7 |
*/ |
|
8 |
|
|
9 |
#import <Foundation/Foundation.h> |
|
10 |
|
|
11 |
#import <FBSDKCoreKit/FBSDKGraphRequestConnecting.h> |
|
12 |
#import <FBSDKCoreKit/FBSDKGraphRequestConnectionFactoryProtocol.h> |
|
13 |
#import <FBSDKCoreKit/FBSDKGraphRequestHTTPMethod.h> |
|
14 |
#import <FBSDKCoreKit/FBSDKGraphRequestProtocol.h> |
|
15 |
#import <FBSDKCoreKit/FBSDKSettingsProtocol.h> |
|
16 |
#import <FBSDKCoreKit/FBSDKTokenStringProviding.h> |
|
17 |
|
|
18 |
NS_ASSUME_NONNULL_BEGIN |
|
19 |
/** |
|
20 |
Represents a request to the Facebook Graph API. |
|
21 |
|
|
22 |
|
|
23 |
`FBSDKGraphRequest` encapsulates the components of a request (the |
|
24 |
Graph API path, the parameters, error recovery behavior) and should be |
|
25 |
used in conjunction with `FBSDKGraphRequestConnection` to issue the request. |
|
26 |
|
|
27 |
Nearly all Graph APIs require an access token. Unless specified, the |
|
28 |
`[FBSDKAccessToken currentAccessToken]` is used. Therefore, most requests |
|
29 |
will require login first (see `FBSDKLoginManager` in FBSDKLoginKit.framework). |
|
30 |
|
|
31 |
A `- start` method is provided for convenience for single requests. |
|
32 |
|
|
33 |
By default, FBSDKGraphRequest will attempt to recover any errors returned from |
|
34 |
Facebook. You can disable this via `disableErrorRecovery:`. |
|
35 |
|
|
36 |
@see FBSDKGraphErrorRecoveryProcessor |
|
37 |
*/ |
|
38 |
NS_SWIFT_NAME(GraphRequest) |
|
39 |
@interface FBSDKGraphRequest : NSObject <FBSDKGraphRequest> |
|
40 |
|
|
41 |
- (instancetype)init NS_UNAVAILABLE; |
|
42 |
+ (instancetype)new NS_UNAVAILABLE; |
|
43 |
|
|
44 |
/** |
|
45 |
Internal method exposed to facilitate transition to Swift. |
|
46 |
API Subject to change or removal without warning. Do not use. |
|
47 |
|
|
48 |
@warning INTERNAL - DO NOT USE |
|
49 |
*/ |
|
50 |
// UNCRUSTIFY_FORMAT_OFF |
|
51 |
+ (void) configureWithSettings:(id<FBSDKSettings>)settings |
|
52 |
currentAccessTokenStringProvider:(Class<FBSDKTokenStringProviding>)accessTokenProvider |
|
53 |
graphRequestConnectionFactory:(id<FBSDKGraphRequestConnectionFactory>)_graphRequestConnectionFactory |
|
54 |
NS_SWIFT_NAME(configure(settings:currentAccessTokenStringProvider:graphRequestConnectionFactory:)); |
|
55 |
// UNCRUSTIFY_FORMAT_ON |
|
56 |
|
|
57 |
/** |
|
58 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
|
59 |
@param graphPath the graph path (e.g., @"me"). |
|
60 |
*/ |
|
61 |
- (instancetype)initWithGraphPath:(NSString *)graphPath; |
|
62 |
|
|
63 |
/** |
|
64 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
|
65 |
@param graphPath the graph path (e.g., @"me"). |
|
66 |
@param method the HTTP method. Empty String defaults to @"GET". |
|
67 |
*/ |
|
68 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
69 |
HTTPMethod:(FBSDKHTTPMethod)method; |
|
70 |
|
|
71 |
/** |
|
72 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
|
73 |
@param graphPath the graph path (e.g., @"me"). |
|
74 |
@param parameters the optional parameters dictionary. |
|
75 |
*/ |
|
76 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
77 |
parameters:(NSDictionary<NSString *, id> *)parameters; |
|
78 |
|
|
79 |
/** |
|
80 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
|
81 |
@param graphPath the graph path (e.g., @"me"). |
|
82 |
@param parameters the optional parameters dictionary. |
|
83 |
@param method the HTTP method. Empty String defaults to @"GET". |
|
84 |
*/ |
|
85 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
86 |
parameters:(NSDictionary<NSString *, id> *)parameters |
|
87 |
HTTPMethod:(FBSDKHTTPMethod)method; |
|
88 |
|
|
89 |
/** |
|
90 |
Initializes a new instance. |
|
91 |
@param graphPath the graph path (e.g., @"me"). |
|
92 |
@param parameters the optional parameters dictionary. |
|
93 |
@param tokenString the token string to use. Specifying nil will cause no token to be used. |
|
94 |
@param version the optional Graph API version (e.g., @"v2.0"). nil defaults to `[FBSDKSettings graphAPIVersion]`. |
|
95 |
@param method the HTTP method. Empty String defaults to @"GET". |
|
96 |
*/ |
|
97 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
98 |
parameters:(NSDictionary<NSString *, id> *)parameters |
|
99 |
tokenString:(nullable NSString *)tokenString |
|
100 |
version:(nullable NSString *)version |
|
101 |
HTTPMethod:(FBSDKHTTPMethod)method |
|
102 |
NS_DESIGNATED_INITIALIZER; |
|
103 |
|
|
104 |
/** |
|
105 |
Initializes a new instance. |
|
106 |
@param graphPath the graph path (e.g., @"me"). |
|
107 |
@param parameters the optional parameters dictionary. |
|
108 |
@param requestFlags flags that indicate how a graph request should be treated in various scenarios |
|
109 |
*/ |
|
110 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
111 |
parameters:(nullable NSDictionary<NSString *, id> *)parameters |
|
112 |
flags:(FBSDKGraphRequestFlags)requestFlags; |
|
113 |
|
|
114 |
/** |
|
115 |
Initializes a new instance. |
|
116 |
@param graphPath the graph path (e.g., @"me"). |
|
117 |
@param parameters the optional parameters dictionary. |
|
118 |
@param tokenString the token string to use. Specifying nil will cause no token to be used. |
|
119 |
@param HTTPMethod the HTTP method. Empty String defaults to @"GET". |
|
120 |
@param flags flags that indicate how a graph request should be treated in various scenarios |
|
121 |
*/ |
|
122 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
123 |
parameters:(nullable NSDictionary<NSString *, id> *)parameters |
|
124 |
tokenString:(nullable NSString *)tokenString |
|
125 |
HTTPMethod:(nullable NSString *)HTTPMethod |
|
126 |
flags:(FBSDKGraphRequestFlags)flags; |
|
127 |
|
|
128 |
/** |
|
129 |
The request parameters. |
|
130 |
*/ |
|
131 |
@property (nonatomic, copy) NSDictionary<NSString *, id> *parameters; |
|
132 |
|
|
133 |
/** |
|
134 |
The access token string used by the request. |
|
135 |
*/ |
|
136 |
@property (nullable, nonatomic, readonly, copy) NSString *tokenString; |
|
137 |
|
|
138 |
/** |
|
139 |
The Graph API endpoint to use for the request, for example "me". |
|
140 |
*/ |
|
141 |
@property (nonatomic, readonly, copy) NSString *graphPath; |
|
142 |
|
|
143 |
/** |
|
144 |
The HTTPMethod to use for the request, for example "GET" or "POST". |
|
145 |
*/ |
|
146 |
@property (nonatomic, readonly, copy) FBSDKHTTPMethod HTTPMethod; |
|
147 |
|
|
148 |
/** |
|
149 |
The Graph API version to use (e.g., "v2.0") |
|
150 |
*/ |
|
151 |
@property (nonatomic, readonly, copy) NSString *version; |
|
152 |
|
|
153 |
/** |
|
154 |
If set, disables the automatic error recovery mechanism. |
|
155 |
@param disable whether to disable the automatic error recovery mechanism |
|
156 |
|
|
157 |
By default, non-batched FBSDKGraphRequest instances will automatically try to recover |
|
158 |
from errors by constructing a `FBSDKGraphErrorRecoveryProcessor` instance that |
|
159 |
re-issues the request on successful recoveries. The re-issued request will call the same |
|
160 |
handler as the receiver but may occur with a different `FBSDKGraphRequestConnection` instance. |
|
161 |
|
|
162 |
This will override [FBSDKSettings setGraphErrorRecoveryDisabled:]. |
|
163 |
*/ |
|
164 |
|
|
165 |
// UNCRUSTIFY_FORMAT_OFF |
|
166 |
- (void)setGraphErrorRecoveryDisabled:(BOOL)disable |
|
167 |
NS_SWIFT_NAME(setGraphErrorRecovery(disabled:)); |
|
168 |
// UNCRUSTIFY_FORMAT_ON |
|
169 |
|
|
170 |
/** |
|
171 |
Starts a connection to the Graph API. |
|
172 |
@param completion The handler block to call when the request completes. |
|
173 |
*/ |
|
174 |
- (id<FBSDKGraphRequestConnecting>)startWithCompletion:(nullable FBSDKGraphRequestCompletion)completion; |
|
175 |
|
|
176 |
@end |
|
177 |
|
|
178 |
NS_ASSUME_NONNULL_END |