hank
2019-01-22 bf63695cd124ba0c3127f4cc8aa99c737729dd1d
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
13e53a 42  @see FBSDKGraphErrorRecoveryProcessor
bad748 43  */
W 44 @interface FBSDKGraphRequest : NSObject
45
13e53a 46 - (instancetype)init NS_UNAVAILABLE;
H 47 + (instancetype)new NS_UNAVAILABLE;
48
9febd9 49 /**
W 50   Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`.
13e53a 51  @param graphPath the graph path (e.g., @"me").
H 52  @param parameters the optional parameters dictionary.
bad748 53  */
W 54 - (instancetype)initWithGraphPath:(NSString *)graphPath
55                        parameters:(NSDictionary *)parameters;
56
9febd9 57 /**
W 58   Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`.
13e53a 59  @param graphPath the graph path (e.g., @"me").
H 60  @param parameters the optional parameters dictionary.
61  @param HTTPMethod the optional HTTP method. nil defaults to @"GET".
bad748 62  */
W 63 - (instancetype)initWithGraphPath:(NSString *)graphPath
64                        parameters:(NSDictionary *)parameters
65                        HTTPMethod:(NSString *)HTTPMethod;
66
9febd9 67 /**
W 68   Initializes a new instance.
13e53a 69  @param graphPath the graph path (e.g., @"me").
H 70  @param parameters the optional parameters dictionary.
71  @param tokenString the token string to use. Specifying nil will cause no token to be used.
72  @param version the optional Graph API version (e.g., @"v2.0"). nil defaults to `[FBSDKSettings graphAPIVersion]`.
73  @param HTTPMethod the optional HTTP method (e.g., @"POST"). nil defaults to @"GET".
bad748 74  */
W 75 - (instancetype)initWithGraphPath:(NSString *)graphPath
76                        parameters:(NSDictionary *)parameters
77                       tokenString:(NSString *)tokenString
78                           version:(NSString *)version
79                        HTTPMethod:(NSString *)HTTPMethod
80 NS_DESIGNATED_INITIALIZER;
81
9febd9 82 /**
W 83   The request parameters.
bad748 84  */
W 85 @property (nonatomic, strong, readonly) NSMutableDictionary *parameters;
86
9febd9 87 /**
W 88   The access token string used by the request.
bad748 89  */
W 90 @property (nonatomic, copy, readonly) NSString *tokenString;
91
9febd9 92 /**
W 93   The Graph API endpoint to use for the request, for example "me".
bad748 94  */
W 95 @property (nonatomic, copy, readonly) NSString *graphPath;
96
9febd9 97 /**
W 98   The HTTPMethod to use for the request, for example "GET" or "POST".
bad748 99  */
W 100 @property (nonatomic, copy, readonly) NSString *HTTPMethod;
101
9febd9 102 /**
W 103   The Graph API version to use (e.g., "v2.0")
bad748 104  */
W 105 @property (nonatomic, copy, readonly) NSString *version;
106
9febd9 107 /**
W 108   If set, disables the automatic error recovery mechanism.
13e53a 109  @param disable whether to disable the automatic error recovery mechanism
9febd9 110
W 111  By default, non-batched FBSDKGraphRequest instances will automatically try to recover
bad748 112  from errors by constructing a `FBSDKGraphErrorRecoveryProcessor` instance that
W 113  re-issues the request on successful recoveries. The re-issued request will call the same
114  handler as the receiver but may occur with a different `FBSDKGraphRequestConnection` instance.
115
116  This will override [FBSDKSettings setGraphErrorRecoveryDisabled:].
117  */
118 - (void)setGraphErrorRecoveryDisabled:(BOOL)disable;
119
9febd9 120 /**
W 121   Starts a connection to the Graph API.
13e53a 122  @param handler The handler block to call when the request completes.
bad748 123  */
W 124 - (FBSDKGraphRequestConnection *)startWithCompletionHandler:(FBSDKGraphRequestHandler)handler;
125
126 @end