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