commit | author | age
|
e0ec42
|
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/FBSDKTokenStringProviding.h> |
|
16 |
|
|
17 |
@protocol FBSDKSettings; |
|
18 |
|
|
19 |
NS_ASSUME_NONNULL_BEGIN |
|
20 |
/** |
|
21 |
Represents a request to the Facebook Graph API. |
|
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"). |
97fc0a
|
66 |
*/ |
L |
67 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
68 |
useAlternativeDefaultDomainPrefix:(BOOL)useAlternativeDefaultDomainPrefix; |
|
69 |
|
|
70 |
/** |
|
71 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
|
72 |
@param graphPath the graph path (e.g., @"me"). |
e0ec42
|
73 |
@param method the HTTP method. Empty String defaults to @"GET". |
L |
74 |
*/ |
|
75 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
76 |
HTTPMethod:(FBSDKHTTPMethod)method; |
|
77 |
|
|
78 |
/** |
|
79 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
|
80 |
@param graphPath the graph path (e.g., @"me"). |
|
81 |
@param parameters the optional parameters dictionary. |
|
82 |
*/ |
|
83 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
84 |
parameters:(NSDictionary<NSString *, id> *)parameters; |
|
85 |
|
|
86 |
/** |
|
87 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
|
88 |
@param graphPath the graph path (e.g., @"me"). |
|
89 |
@param parameters the optional parameters dictionary. |
97fc0a
|
90 |
*/ |
L |
91 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
92 |
parameters:(NSDictionary<NSString *, id> *)parameters |
|
93 |
useAlternativeDefaultDomainPrefix:(BOOL)useAlternativeDefaultDomainPrefix; |
|
94 |
|
|
95 |
/** |
|
96 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
|
97 |
@param graphPath the graph path (e.g., @"me"). |
|
98 |
@param parameters the optional parameters dictionary. |
e0ec42
|
99 |
@param method the HTTP method. Empty String defaults to @"GET". |
L |
100 |
*/ |
|
101 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
102 |
parameters:(NSDictionary<NSString *, id> *)parameters |
|
103 |
HTTPMethod:(FBSDKHTTPMethod)method; |
97fc0a
|
104 |
|
L |
105 |
/** |
|
106 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
|
107 |
@param graphPath the graph path (e.g., @"me"). |
|
108 |
@param parameters the optional parameters dictionary. |
|
109 |
@param method the HTTP method. Empty String defaults to @"GET". |
|
110 |
*/ |
|
111 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
112 |
parameters:(NSDictionary<NSString *, id> *)parameters |
|
113 |
HTTPMethod:(FBSDKHTTPMethod)method |
|
114 |
useAlternativeDefaultDomainPrefix:(BOOL)useAlternativeDefaultDomainPrefix; |
e0ec42
|
115 |
|
L |
116 |
/** |
|
117 |
Initializes a new instance. |
|
118 |
@param graphPath the graph path (e.g., @"me"). |
|
119 |
@param parameters the optional parameters dictionary. |
|
120 |
@param tokenString the token string to use. Specifying nil will cause no token to be used. |
|
121 |
@param version the optional Graph API version (e.g., @"v2.0"). nil defaults to `[FBSDKSettings graphAPIVersion]`. |
|
122 |
@param method the HTTP method. Empty String defaults to @"GET". |
|
123 |
*/ |
|
124 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
125 |
parameters:(NSDictionary<NSString *, id> *)parameters |
|
126 |
tokenString:(nullable NSString *)tokenString |
|
127 |
version:(nullable NSString *)version |
97fc0a
|
128 |
HTTPMethod:(FBSDKHTTPMethod)method; |
L |
129 |
|
|
130 |
/** |
|
131 |
Initializes a new instance. |
|
132 |
@param graphPath the graph path (e.g., @"me"). |
|
133 |
@param parameters the optional parameters dictionary. |
|
134 |
@param tokenString the token string to use. Specifying nil will cause no token to be used. |
|
135 |
@param version the optional Graph API version (e.g., @"v2.0"). nil defaults to `[FBSDKSettings graphAPIVersion]`. |
|
136 |
@param method the HTTP method. Empty String defaults to @"GET". |
|
137 |
@param forAppEvents a convenience flag indicating if the request is for sending app events. |
|
138 |
*/ |
|
139 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
140 |
parameters:(NSDictionary<NSString *, id> *)parameters |
|
141 |
tokenString:(nullable NSString *)tokenString |
|
142 |
version:(nullable NSString *)version |
e0ec42
|
143 |
HTTPMethod:(FBSDKHTTPMethod)method |
97fc0a
|
144 |
forAppEvents:(BOOL)forAppEvents; |
L |
145 |
|
|
146 |
/** |
|
147 |
Initializes a new instance. |
|
148 |
@param graphPath the graph path (e.g., @"me"). |
|
149 |
@param parameters the optional parameters dictionary. |
|
150 |
@param tokenString the token string to use. Specifying nil will cause no token to be used. |
|
151 |
@param version the optional Graph API version (e.g., @"v2.0"). nil defaults to `[FBSDKSettings graphAPIVersion]`. |
|
152 |
@param method the HTTP method. Empty String defaults to @"GET". |
|
153 |
@param forAppEvents a convenience flag indicating if the request is for sending app events. |
|
154 |
*/ |
|
155 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
156 |
parameters:(NSDictionary<NSString *, id> *)parameters |
|
157 |
tokenString:(nullable NSString *)tokenString |
|
158 |
version:(nullable NSString *)version |
|
159 |
HTTPMethod:(FBSDKHTTPMethod)method |
|
160 |
forAppEvents:(BOOL)forAppEvents |
|
161 |
useAlternativeDefaultDomainPrefix:(BOOL)useAlternativeDefaultDomainPrefix |
e0ec42
|
162 |
NS_DESIGNATED_INITIALIZER; |
L |
163 |
|
|
164 |
/** |
|
165 |
Initializes a new instance. |
|
166 |
@param graphPath the graph path (e.g., @"me"). |
|
167 |
@param parameters the optional parameters dictionary. |
|
168 |
@param requestFlags flags that indicate how a graph request should be treated in various scenarios |
|
169 |
*/ |
|
170 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
171 |
parameters:(nullable NSDictionary<NSString *, id> *)parameters |
|
172 |
flags:(FBSDKGraphRequestFlags)requestFlags; |
|
173 |
|
|
174 |
/** |
|
175 |
Initializes a new instance. |
|
176 |
@param graphPath the graph path (e.g., @"me"). |
|
177 |
@param parameters the optional parameters dictionary. |
97fc0a
|
178 |
@param requestFlags flags that indicate how a graph request should be treated in various scenarios |
L |
179 |
*/ |
|
180 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
181 |
parameters:(nullable NSDictionary<NSString *, id> *)parameters |
|
182 |
flags:(FBSDKGraphRequestFlags)requestFlags |
|
183 |
useAlternativeDefaultDomainPrefix:(BOOL)useAlternativeDefaultDomainPrefix; |
|
184 |
|
|
185 |
/** |
|
186 |
Initializes a new instance. |
|
187 |
@param graphPath the graph path (e.g., @"me"). |
|
188 |
@param parameters the optional parameters dictionary. |
e0ec42
|
189 |
@param tokenString the token string to use. Specifying nil will cause no token to be used. |
L |
190 |
@param HTTPMethod the HTTP method. Empty String defaults to @"GET". |
|
191 |
@param flags flags that indicate how a graph request should be treated in various scenarios |
|
192 |
*/ |
|
193 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
194 |
parameters:(nullable NSDictionary<NSString *, id> *)parameters |
|
195 |
tokenString:(nullable NSString *)tokenString |
|
196 |
HTTPMethod:(nullable NSString *)HTTPMethod |
|
197 |
flags:(FBSDKGraphRequestFlags)flags; |
97fc0a
|
198 |
|
L |
199 |
/** |
|
200 |
Initializes a new instance. |
|
201 |
@param graphPath the graph path (e.g., @"me"). |
|
202 |
@param parameters the optional parameters dictionary. |
|
203 |
@param tokenString the token string to use. Specifying nil will cause no token to be used. |
|
204 |
@param HTTPMethod the HTTP method. Empty String defaults to @"GET". |
|
205 |
@param flags flags that indicate how a graph request should be treated in various scenarios |
|
206 |
*/ |
|
207 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
208 |
parameters:(nullable NSDictionary<NSString *, id> *)parameters |
|
209 |
tokenString:(nullable NSString *)tokenString |
|
210 |
HTTPMethod:(nullable NSString *)HTTPMethod |
|
211 |
flags:(FBSDKGraphRequestFlags)flags |
|
212 |
useAlternativeDefaultDomainPrefix:(BOOL)useAlternativeDefaultDomainPrefix;; |
|
213 |
|
|
214 |
/** |
|
215 |
Initializes a new instance. |
|
216 |
@param graphPath the graph path (e.g., @"me"). |
|
217 |
@param parameters the optional parameters dictionary. |
|
218 |
@param tokenString the token string to use. Specifying nil will cause no token to be used. |
|
219 |
@param method the HTTP method. Empty String defaults to @"GET". |
|
220 |
@param requestFlags flags that indicate how a graph request should be treated in various scenarios |
|
221 |
@param forAppEvents a convenience flag indicating if the request is for sending app events. |
|
222 |
*/ |
|
223 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
224 |
parameters:(nullable NSDictionary<NSString *, id> *)parameters |
|
225 |
tokenString:(nullable NSString *)tokenString |
|
226 |
HTTPMethod:(nullable NSString *)method |
|
227 |
flags:(FBSDKGraphRequestFlags)requestFlags |
|
228 |
forAppEvents:(BOOL)forAppEvents; |
|
229 |
|
|
230 |
/** |
|
231 |
Initializes a new instance. |
|
232 |
@param graphPath the graph path (e.g., @"me"). |
|
233 |
@param parameters the optional parameters dictionary. |
|
234 |
@param tokenString the token string to use. Specifying nil will cause no token to be used. |
|
235 |
@param method the HTTP method. Empty String defaults to @"GET". |
|
236 |
@param requestFlags flags that indicate how a graph request should be treated in various scenarios |
|
237 |
@param forAppEvents a convenience flag indicating if the request is for sending app events. |
|
238 |
*/ |
|
239 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
240 |
parameters:(nullable NSDictionary<NSString *, id> *)parameters |
|
241 |
tokenString:(nullable NSString *)tokenString |
|
242 |
HTTPMethod:(nullable NSString *)method |
|
243 |
flags:(FBSDKGraphRequestFlags)requestFlags |
|
244 |
forAppEvents:(BOOL)forAppEvents |
|
245 |
useAlternativeDefaultDomainPrefix:(BOOL)useAlternativeDefaultDomainPrefix; |
e0ec42
|
246 |
|
L |
247 |
/// The request parameters. |
|
248 |
@property (nonatomic, copy) NSDictionary<NSString *, id> *parameters; |
|
249 |
|
|
250 |
/// The access token string used by the request. |
|
251 |
@property (nullable, nonatomic, readonly, copy) NSString *tokenString; |
|
252 |
|
|
253 |
/// The Graph API endpoint to use for the request, for example "me". |
|
254 |
@property (nonatomic, readonly, copy) NSString *graphPath; |
|
255 |
|
|
256 |
/// The HTTPMethod to use for the request, for example "GET" or "POST". |
|
257 |
@property (nonatomic, readonly, copy) FBSDKHTTPMethod HTTPMethod; |
|
258 |
|
|
259 |
/// The Graph API version to use (e.g., "v2.0") |
|
260 |
@property (nonatomic, readonly, copy) NSString *version; |
|
261 |
|
97fc0a
|
262 |
@property (nonatomic, readonly, assign) BOOL forAppEvents; |
L |
263 |
|
|
264 |
@property (nonatomic, readonly, assign) BOOL useAlternativeDefaultDomainPrefix; |
|
265 |
|
e0ec42
|
266 |
/** |
L |
267 |
If set, disables the automatic error recovery mechanism. |
|
268 |
@param disable whether to disable the automatic error recovery mechanism |
|
269 |
|
|
270 |
By default, non-batched FBSDKGraphRequest instances will automatically try to recover |
|
271 |
from errors by constructing a `FBSDKGraphErrorRecoveryProcessor` instance that |
|
272 |
re-issues the request on successful recoveries. The re-issued request will call the same |
|
273 |
handler as the receiver but may occur with a different `FBSDKGraphRequestConnection` instance. |
|
274 |
|
|
275 |
This will override [FBSDKSettings setGraphErrorRecoveryDisabled:]. |
|
276 |
*/ |
|
277 |
|
|
278 |
// UNCRUSTIFY_FORMAT_OFF |
|
279 |
- (void)setGraphErrorRecoveryDisabled:(BOOL)disable |
|
280 |
NS_SWIFT_NAME(setGraphErrorRecovery(disabled:)); |
|
281 |
// UNCRUSTIFY_FORMAT_ON |
|
282 |
|
|
283 |
/** |
|
284 |
Starts a connection to the Graph API. |
|
285 |
@param completion The handler block to call when the request completes. |
|
286 |
*/ |
|
287 |
- (id<FBSDKGraphRequestConnecting>)startWithCompletion:(nullable FBSDKGraphRequestCompletion)completion; |
|
288 |
|
|
289 |
@end |
|
290 |
|
|
291 |
NS_ASSUME_NONNULL_END |