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