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 |
|
b19a78
|
21 |
#import "FBSDKGraphRequestProtocol.h" |
L |
22 |
#import "FBSDKGraphRequestHTTPMethod.h" |
bad748
|
23 |
|
e81c27
|
24 |
NS_ASSUME_NONNULL_BEGIN |
H |
25 |
|
bad748
|
26 |
@class FBSDKAccessToken; |
b19a78
|
27 |
@protocol FBSDKGraphRequestConnecting; |
bad748
|
28 |
|
9febd9
|
29 |
/** |
W |
30 |
Represents a request to the Facebook Graph API. |
bad748
|
31 |
|
9febd9
|
32 |
|
W |
33 |
`FBSDKGraphRequest` encapsulates the components of a request (the |
bad748
|
34 |
Graph API path, the parameters, error recovery behavior) and should be |
W |
35 |
used in conjunction with `FBSDKGraphRequestConnection` to issue the request. |
|
36 |
|
|
37 |
Nearly all Graph APIs require an access token. Unless specified, the |
|
38 |
`[FBSDKAccessToken currentAccessToken]` is used. Therefore, most requests |
|
39 |
will require login first (see `FBSDKLoginManager` in FBSDKLoginKit.framework). |
|
40 |
|
|
41 |
A `- start` method is provided for convenience for single requests. |
|
42 |
|
|
43 |
By default, FBSDKGraphRequest will attempt to recover any errors returned from |
|
44 |
Facebook. You can disable this via `disableErrorRecovery:`. |
9febd9
|
45 |
|
13e53a
|
46 |
@see FBSDKGraphErrorRecoveryProcessor |
bad748
|
47 |
*/ |
e81c27
|
48 |
NS_SWIFT_NAME(GraphRequest) |
b19a78
|
49 |
@interface FBSDKGraphRequest : NSObject <FBSDKGraphRequest> |
bad748
|
50 |
|
13e53a
|
51 |
- (instancetype)init NS_UNAVAILABLE; |
H |
52 |
+ (instancetype)new NS_UNAVAILABLE; |
|
53 |
|
9febd9
|
54 |
/** |
e81c27
|
55 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
13e53a
|
56 |
@param graphPath the graph path (e.g., @"me"). |
e81c27
|
57 |
*/ |
H |
58 |
- (instancetype)initWithGraphPath:(NSString *)graphPath; |
|
59 |
|
|
60 |
/** |
|
61 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
|
62 |
@param graphPath the graph path (e.g., @"me"). |
|
63 |
@param method the HTTP method. Empty String defaults to @"GET". |
bad748
|
64 |
*/ |
W |
65 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
e81c27
|
66 |
HTTPMethod:(FBSDKHTTPMethod)method; |
bad748
|
67 |
|
9febd9
|
68 |
/** |
W |
69 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
13e53a
|
70 |
@param graphPath the graph path (e.g., @"me"). |
H |
71 |
@param parameters the optional parameters dictionary. |
bad748
|
72 |
*/ |
W |
73 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
e81c27
|
74 |
parameters:(NSDictionary<NSString *, id> *)parameters; |
H |
75 |
|
|
76 |
/** |
|
77 |
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`. |
|
78 |
@param graphPath the graph path (e.g., @"me"). |
|
79 |
@param parameters the optional parameters dictionary. |
|
80 |
@param method the HTTP method. Empty String defaults to @"GET". |
|
81 |
*/ |
|
82 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
|
83 |
parameters:(NSDictionary<NSString *, id> *)parameters |
|
84 |
HTTPMethod:(FBSDKHTTPMethod)method; |
bad748
|
85 |
|
9febd9
|
86 |
/** |
W |
87 |
Initializes a new instance. |
13e53a
|
88 |
@param graphPath the graph path (e.g., @"me"). |
H |
89 |
@param parameters the optional parameters dictionary. |
|
90 |
@param tokenString the token string to use. Specifying nil will cause no token to be used. |
|
91 |
@param version the optional Graph API version (e.g., @"v2.0"). nil defaults to `[FBSDKSettings graphAPIVersion]`. |
e81c27
|
92 |
@param method the HTTP method. Empty String defaults to @"GET". |
bad748
|
93 |
*/ |
W |
94 |
- (instancetype)initWithGraphPath:(NSString *)graphPath |
e81c27
|
95 |
parameters:(NSDictionary<NSString *, id> *)parameters |
H |
96 |
tokenString:(nullable NSString *)tokenString |
|
97 |
version:(nullable NSString *)version |
|
98 |
HTTPMethod:(FBSDKHTTPMethod)method |
bad748
|
99 |
NS_DESIGNATED_INITIALIZER; |
W |
100 |
|
9febd9
|
101 |
/** |
W |
102 |
The request parameters. |
bad748
|
103 |
*/ |
e81c27
|
104 |
@property (nonatomic, copy) NSDictionary<NSString *, id> *parameters; |
bad748
|
105 |
|
9febd9
|
106 |
/** |
W |
107 |
The access token string used by the request. |
bad748
|
108 |
*/ |
e81c27
|
109 |
@property (nonatomic, copy, readonly, nullable) NSString *tokenString; |
bad748
|
110 |
|
9febd9
|
111 |
/** |
W |
112 |
The Graph API endpoint to use for the request, for example "me". |
bad748
|
113 |
*/ |
W |
114 |
@property (nonatomic, copy, readonly) NSString *graphPath; |
|
115 |
|
9febd9
|
116 |
/** |
W |
117 |
The HTTPMethod to use for the request, for example "GET" or "POST". |
bad748
|
118 |
*/ |
e81c27
|
119 |
@property (nonatomic, copy, readonly) FBSDKHTTPMethod HTTPMethod; |
bad748
|
120 |
|
9febd9
|
121 |
/** |
W |
122 |
The Graph API version to use (e.g., "v2.0") |
bad748
|
123 |
*/ |
W |
124 |
@property (nonatomic, copy, readonly) NSString *version; |
|
125 |
|
9febd9
|
126 |
/** |
W |
127 |
If set, disables the automatic error recovery mechanism. |
13e53a
|
128 |
@param disable whether to disable the automatic error recovery mechanism |
9febd9
|
129 |
|
W |
130 |
By default, non-batched FBSDKGraphRequest instances will automatically try to recover |
bad748
|
131 |
from errors by constructing a `FBSDKGraphErrorRecoveryProcessor` instance that |
W |
132 |
re-issues the request on successful recoveries. The re-issued request will call the same |
|
133 |
handler as the receiver but may occur with a different `FBSDKGraphRequestConnection` instance. |
|
134 |
|
|
135 |
This will override [FBSDKSettings setGraphErrorRecoveryDisabled:]. |
|
136 |
*/ |
e81c27
|
137 |
- (void)setGraphErrorRecoveryDisabled:(BOOL)disable |
H |
138 |
NS_SWIFT_NAME(setGraphErrorRecovery(disabled:)); |
bad748
|
139 |
|
9febd9
|
140 |
/** |
W |
141 |
Starts a connection to the Graph API. |
13e53a
|
142 |
@param handler The handler block to call when the request completes. |
bad748
|
143 |
*/ |
b19a78
|
144 |
- (id<FBSDKGraphRequestConnecting>)startWithCompletionHandler:(nullable FBSDKGraphRequestBlock)handler; |
bad748
|
145 |
|
W |
146 |
@end |
e81c27
|
147 |
|
H |
148 |
NS_ASSUME_NONNULL_END |