commit | author | age
|
bad748
|
1 |
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
W |
2 |
// |
|
3 |
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use, |
|
4 |
// copy, modify, and distribute this software in source code or binary form for use |
|
5 |
// in connection with the web services and APIs provided by Facebook. |
|
6 |
// |
|
7 |
// As with any software that integrates with the Facebook platform, your use of |
|
8 |
// this software is subject to the Facebook Developer Principles and Policies |
|
9 |
// [http://developers.facebook.com/policy/]. This copyright notice shall be |
|
10 |
// included in all copies or substantial portions of the software. |
|
11 |
// |
|
12 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
13 |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|
14 |
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
15 |
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|
16 |
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
17 |
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
18 |
|
|
19 |
#import <Foundation/Foundation.h> |
|
20 |
|
|
21 |
#import <FBSDKCoreKit/FBSDKGraphRequestConnection.h> |
|
22 |
|
e81c27
|
23 |
NS_ASSUME_NONNULL_BEGIN |
H |
24 |
|
bad748
|
25 |
@class FBSDKAccessToken; |
e81c27
|
26 |
|
H |
27 |
/// typedef for FBSDKHTTPMethod |
|
28 |
typedef NSString *const FBSDKHTTPMethod NS_TYPED_EXTENSIBLE_ENUM NS_SWIFT_NAME(HTTPMethod); |
|
29 |
|
|
30 |
/// GET Request |
|
31 |
FOUNDATION_EXPORT FBSDKHTTPMethod FBSDKHTTPMethodGET NS_SWIFT_NAME(get); |
|
32 |
|
|
33 |
/// POST Request |
|
34 |
FOUNDATION_EXPORT FBSDKHTTPMethod FBSDKHTTPMethodPOST NS_SWIFT_NAME(post); |
|
35 |
|
|
36 |
/// DELETE Request |
|
37 |
FOUNDATION_EXPORT FBSDKHTTPMethod FBSDKHTTPMethodDELETE NS_SWIFT_NAME(delete); |
bad748
|
38 |
|
9febd9
|
39 |
/** |
W |
40 |
Represents a request to the Facebook Graph API. |
bad748
|
41 |
|
9febd9
|
42 |
|
W |
43 |
`FBSDKGraphRequest` encapsulates the components of a request (the |
bad748
|
44 |
Graph API path, the parameters, error recovery behavior) and should be |
W |
45 |
used in conjunction with `FBSDKGraphRequestConnection` to issue the request. |
|
46 |
|
|
47 |
Nearly all Graph APIs require an access token. Unless specified, the |
|
48 |
`[FBSDKAccessToken currentAccessToken]` is used. Therefore, most requests |
|
49 |
will require login first (see `FBSDKLoginManager` in FBSDKLoginKit.framework). |
|
50 |
|
|
51 |
A `- start` method is provided for convenience for single requests. |
|
52 |
|
|
53 |
By default, FBSDKGraphRequest will attempt to recover any errors returned from |
|
54 |
Facebook. You can disable this via `disableErrorRecovery:`. |
9febd9
|
55 |
|
13e53a
|
56 |
@see FBSDKGraphErrorRecoveryProcessor |
bad748
|
57 |
*/ |
e81c27
|
58 |
NS_SWIFT_NAME(GraphRequest) |
bad748
|
59 |
@interface FBSDKGraphRequest : NSObject |
W |
60 |
|
13e53a
|
61 |
- (instancetype)init NS_UNAVAILABLE; |
H |
62 |
+ (instancetype)new NS_UNAVAILABLE; |
|
63 |
|
9febd9
|
64 |
/** |
e81c27
|
65 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
13e53a
|
66 |
@param graphPath the graph path (e.g., @"me"). |
e81c27
|
67 |
*/ |
H |
68 |
- (instancetype)initWithGraphPath:(NSString *)graphPath; |
|
69 |
|
|
70 |
/** |
|
71 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
|
72 |
@param graphPath the graph path (e.g., @"me"). |
|
73 |
@param method the HTTP method. Empty String defaults to @"GET". |
bad748
|
74 |
*/ |
W |
75 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
e81c27
|
76 |
HTTPMethod:(FBSDKHTTPMethod)method; |
bad748
|
77 |
|
9febd9
|
78 |
/** |
W |
79 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
13e53a
|
80 |
@param graphPath the graph path (e.g., @"me"). |
H |
81 |
@param parameters the optional parameters dictionary. |
bad748
|
82 |
*/ |
W |
83 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
e81c27
|
84 |
parameters:(NSDictionary<NSString *, id> *)parameters; |
H |
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. |
|
90 |
@param method the HTTP method. Empty String defaults to @"GET". |
|
91 |
*/ |
|
92 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
93 |
parameters:(NSDictionary<NSString *, id> *)parameters |
|
94 |
HTTPMethod:(FBSDKHTTPMethod)method; |
bad748
|
95 |
|
9febd9
|
96 |
/** |
W |
97 |
Initializes a new instance. |
13e53a
|
98 |
@param graphPath the graph path (e.g., @"me"). |
H |
99 |
@param parameters the optional parameters dictionary. |
|
100 |
@param tokenString the token string to use. Specifying nil will cause no token to be used. |
|
101 |
@param version the optional Graph API version (e.g., @"v2.0"). nil defaults to `[FBSDKSettings graphAPIVersion]`. |
e81c27
|
102 |
@param method the HTTP method. Empty String defaults to @"GET". |
bad748
|
103 |
*/ |
W |
104 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
e81c27
|
105 |
parameters:(NSDictionary<NSString *, id> *)parameters |
H |
106 |
tokenString:(nullable NSString *)tokenString |
|
107 |
version:(nullable NSString *)version |
|
108 |
HTTPMethod:(FBSDKHTTPMethod)method |
bad748
|
109 |
NS_DESIGNATED_INITIALIZER; |
W |
110 |
|
9febd9
|
111 |
/** |
W |
112 |
The request parameters. |
bad748
|
113 |
*/ |
e81c27
|
114 |
@property (nonatomic, copy) NSDictionary<NSString *, id> *parameters; |
bad748
|
115 |
|
9febd9
|
116 |
/** |
W |
117 |
The access token string used by the request. |
bad748
|
118 |
*/ |
e81c27
|
119 |
@property (nonatomic, copy, readonly, nullable) NSString *tokenString; |
bad748
|
120 |
|
9febd9
|
121 |
/** |
W |
122 |
The Graph API endpoint to use for the request, for example "me". |
bad748
|
123 |
*/ |
W |
124 |
@property (nonatomic, copy, readonly) NSString *graphPath; |
|
125 |
|
9febd9
|
126 |
/** |
W |
127 |
The HTTPMethod to use for the request, for example "GET" or "POST". |
bad748
|
128 |
*/ |
e81c27
|
129 |
@property (nonatomic, copy, readonly) FBSDKHTTPMethod HTTPMethod; |
bad748
|
130 |
|
9febd9
|
131 |
/** |
W |
132 |
The Graph API version to use (e.g., "v2.0") |
bad748
|
133 |
*/ |
W |
134 |
@property (nonatomic, copy, readonly) NSString *version; |
|
135 |
|
9febd9
|
136 |
/** |
W |
137 |
If set, disables the automatic error recovery mechanism. |
13e53a
|
138 |
@param disable whether to disable the automatic error recovery mechanism |
9febd9
|
139 |
|
W |
140 |
By default, non-batched FBSDKGraphRequest instances will automatically try to recover |
bad748
|
141 |
from errors by constructing a `FBSDKGraphErrorRecoveryProcessor` instance that |
W |
142 |
re-issues the request on successful recoveries. The re-issued request will call the same |
|
143 |
handler as the receiver but may occur with a different `FBSDKGraphRequestConnection` instance. |
|
144 |
|
|
145 |
This will override [FBSDKSettings setGraphErrorRecoveryDisabled:]. |
|
146 |
*/ |
e81c27
|
147 |
- (void)setGraphErrorRecoveryDisabled:(BOOL)disable |
H |
148 |
NS_SWIFT_NAME(setGraphErrorRecovery(disabled:)); |
bad748
|
149 |
|
9febd9
|
150 |
/** |
W |
151 |
Starts a connection to the Graph API. |
13e53a
|
152 |
@param handler The handler block to call when the request completes. |
bad748
|
153 |
*/ |
e81c27
|
154 |
- (FBSDKGraphRequestConnection *)startWithCompletionHandler:(nullable FBSDKGraphRequestBlock)handler; |
bad748
|
155 |
|
W |
156 |
@end |
e81c27
|
157 |
|
H |
158 |
NS_ASSUME_NONNULL_END |