FBRequestConnection.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. /*
  2. * Copyright 2010-present Facebook.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <CoreLocation/CoreLocation.h>
  17. #import <Foundation/Foundation.h>
  18. #import "FBGraphObject.h"
  19. #import "FBSDKMacros.h"
  20. // up-front decl's
  21. @class FBRequest;
  22. @class FBRequestConnection;
  23. @class FBSession;
  24. @class UIImage;
  25. /*!
  26. @attribute beta true
  27. @typedef FBRequestConnectionErrorBehavior enum
  28. @abstract Describes what automatic error handling behaviors to provide (if any).
  29. @discussion This is a bitflag enum that can be composed of different values.
  30. See FBError.h and FBErrorUtility.h for error category and user message details.
  31. */
  32. typedef NS_ENUM(NSUInteger, FBRequestConnectionErrorBehavior) {
  33. /*! The default behavior of none */
  34. FBRequestConnectionErrorBehaviorNone = 0,
  35. /*! This will retry any requests whose error category is classified as `FBErrorCategoryRetry`.
  36. If the retry fails, the normal handler is invoked. */
  37. FBRequestConnectionErrorBehaviorRetry = 1,
  38. /*! This will automatically surface any SDK provided userMessage (at most one), after
  39. retry attempts, but before any reconnects are tried. The alert will have one button
  40. whose text can be localized with the key "FBE:AlertMessageButton".
  41. You should not display your own alert views in your request handler when specifying this
  42. behavior.
  43. */
  44. FBRequestConnectionErrorBehaviorAlertUser = 2,
  45. /*! This will automatically reconnect a session if the request failed due to an invalid token
  46. that would otherwise close the session (such as an expired token or password change). Note
  47. this will NOT reconnect a session if the user had uninstalled the app, or if the user had
  48. disabled the app's slider in their privacy settings (in cases of iOS 6 system auth).
  49. If the session is reconnected, this will transition the session state to FBSessionStateTokenExtended
  50. which will invoke any state change handlers. Otherwise, the session is closed as normal.
  51. This behavior should not be used if the FBRequestConnection contains multiple
  52. session instances. Further, when this behavior is used, you must not request new permissions
  53. for the session until the connection is completed.
  54. Lastly, you should avoid using additional FBRequestConnections with the same session because
  55. that will be subject to race conditions.
  56. */
  57. FBRequestConnectionErrorBehaviorReconnectSession = 4,
  58. };
  59. /*!
  60. Normally requests return JSON data that is parsed into a set of `NSDictionary`
  61. and `NSArray` objects.
  62. When a request returns a non-JSON response, that response is packaged in
  63. a `NSDictionary` using FBNonJSONResponseProperty as the key and the literal
  64. response as the value.
  65. */
  66. FBSDK_EXTERN NSString *const FBNonJSONResponseProperty;
  67. /*!
  68. @typedef FBRequestHandler
  69. @abstract
  70. A block that is passed to addRequest to register for a callback with the results of that
  71. request once the connection completes.
  72. @discussion
  73. Pass a block of this type when calling addRequest. This will be called once
  74. the request completes. The call occurs on the UI thread.
  75. @param connection The `FBRequestConnection` that sent the request.
  76. @param result The result of the request. This is a translation of
  77. JSON data to `NSDictionary` and `NSArray` objects. This
  78. is nil if there was an error.
  79. @param error The `NSError` representing any error that occurred.
  80. */
  81. typedef void (^FBRequestHandler)(FBRequestConnection *connection,
  82. id result,
  83. NSError *error);
  84. /*!
  85. @protocol
  86. @abstract
  87. The `FBRequestConnectionDelegate` protocol defines the methods used to receive network
  88. activity progress information from a <FBRequestConnection>.
  89. */
  90. @protocol FBRequestConnectionDelegate <NSObject>
  91. @optional
  92. /*!
  93. @method
  94. @abstract
  95. Tells the delegate the request connection will begin loading
  96. @discussion
  97. If the <FBRequestConnection> is created using one of the convenience factory methods prefixed with
  98. start, the object returned from the convenience method has already begun loading and this method
  99. will not be called when the delegate is set.
  100. @param connection The request connection that is starting a network request
  101. @param isCached YES if the request can be fulfilled using cached data, otherwise NO indicating
  102. the result will require a network request.
  103. */
  104. - (void)requestConnectionWillBeginLoading:(FBRequestConnection *)connection
  105. fromCache:(BOOL)isCached;
  106. /*!
  107. @method
  108. @abstract
  109. Tells the delegate the request connection finished loading
  110. @discussion
  111. If the request connection completes without a network error occuring then this method is called.
  112. Invocation of this method does not indicate success of every <FBRequest> made, only that the
  113. request connection has no further activity. Use the error argument passed to the FBRequestHandler
  114. block to determine success or failure of each <FBRequest>.
  115. This method is invoked after the completion handler for each <FBRequest>.
  116. @param connection The request connection that successfully completed a network request
  117. @param isCached YES if the request was fulfilled using cached data, otherwise NO indicating
  118. a network request was completed.
  119. */
  120. - (void)requestConnectionDidFinishLoading:(FBRequestConnection *)connection
  121. fromCache:(BOOL)isCached;
  122. /*!
  123. @method
  124. @abstract
  125. Tells the delegate the request connection failed with an error
  126. @discussion
  127. If the request connection fails with a network error then this method is called. The `error`
  128. argument specifies why the network connection failed. The `NSError` object passed to the
  129. FBRequestHandler block may contain additional information.
  130. This method is invoked after the completion handler for each <FBRequest> and only if a network
  131. request was made. If the request was fulfilled using cached data, this method is not called.
  132. @param connection The request connection that successfully completed a network request
  133. @param error The `NSError` representing the network error that occurred, if any. May be nil
  134. in some circumstances. Consult the `NSError` for the <FBRequest> for reliable
  135. failure information.
  136. */
  137. - (void)requestConnection:(FBRequestConnection *)connection
  138. didFailWithError:(NSError *)error;
  139. /*!
  140. @method
  141. @abstract
  142. Tells the delegate the request connection is going to retry some network operations
  143. @discussion
  144. If some <FBRequests> fail, <FBRequestConnection> may create a new instance to retry the failed
  145. requests. This method is called before the new instance is started. You must set the delegate
  146. property on `retryConnection` to continue to receive progress information. If a delegate is
  147. set on `retryConnection` then -requestConnectionWillBeginLoading: will be invoked.
  148. This method is invoked after the completion handler for each <FBRequest> and only if a network
  149. request was made. If the request was fulfilled using cached data, this method is not called.
  150. @param connection The request connection that successfully completed a network request
  151. @param retryConnection The new request connection that will retry the failed <FBRequest>s
  152. */
  153. - (void) requestConnection:(FBRequestConnection *)connection
  154. willRetryWithRequestConnection:(FBRequestConnection *)retryConnection;
  155. /*!
  156. @method
  157. @abstract
  158. Tells the delegate how much data has been sent and is planned to send to the remote host
  159. @discussion
  160. The byte count arguments refer to the aggregated <FBRequest> objects, not a particular <FBRequest>.
  161. Like `NSURLConnection`, the values may change in unexpected ways if data needs to be resent.
  162. @param connection The request connection transmitting data to a remote host
  163. @param bytesWritten The number of bytes sent in the last transmission
  164. @param totalBytesWritten The total number of bytes sent to the remote host
  165. @param totalBytesExpectedToWrite The total number of bytes expected to send to the remote host
  166. */
  167. - (void)requestConnection:(FBRequestConnection *)connection
  168. didSendBodyData:(NSInteger)bytesWritten
  169. totalBytesWritten:(NSInteger)totalBytesWritten
  170. totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
  171. @end
  172. /*!
  173. @class FBRequestConnection
  174. @abstract
  175. The `FBRequestConnection` represents a single connection to Facebook to service a request.
  176. @discussion
  177. The request settings are encapsulated in a reusable <FBRequest> object. The
  178. `FBRequestConnection` object encapsulates the concerns of a single communication
  179. e.g. starting a connection, canceling a connection, or batching requests.
  180. */
  181. @interface FBRequestConnection : NSObject
  182. /*!
  183. @methodgroup Creating a request
  184. */
  185. /*!
  186. @method
  187. Calls <initWithTimeout:> with a default timeout of 180 seconds.
  188. */
  189. - (instancetype)init;
  190. /*!
  191. @method
  192. @abstract
  193. `FBRequestConnection` objects are used to issue one or more requests as a single
  194. request/response connection with Facebook.
  195. @discussion
  196. For a single request, the usual method for creating an `FBRequestConnection`
  197. object is to call one of the **start* ** methods on <FBRequest>. However, it is
  198. allowable to init an `FBRequestConnection` object directly, and call
  199. <addRequest:completionHandler:> to add one or more request objects to the
  200. connection, before calling start.
  201. Note that if requests are part of a batch, they must have an open
  202. FBSession that has an access token associated with it. Alternatively a default App ID
  203. must be set either in the plist or through an explicit call to <[FBSession defaultAppID]>.
  204. @param timeout The `NSTimeInterval` (seconds) to wait for a response before giving up.
  205. */
  206. - (instancetype)initWithTimeout:(NSTimeInterval)timeout;
  207. // properties
  208. /*!
  209. @abstract
  210. The request that will be sent to the server.
  211. @discussion
  212. This property can be used to create a `NSURLRequest` without using
  213. `FBRequestConnection` to send that request. It is legal to set this property
  214. in which case the provided `NSMutableURLRequest` will be used instead. However,
  215. the `NSMutableURLRequest` must result in an appropriate response. Furthermore, once
  216. this property has been set, no more <FBRequest> objects can be added to this
  217. `FBRequestConnection`.
  218. */
  219. @property (nonatomic, retain, readwrite) NSMutableURLRequest *urlRequest;
  220. /*!
  221. @abstract
  222. The raw response that was returned from the server. (readonly)
  223. @discussion
  224. This property can be used to inspect HTTP headers that were returned from
  225. the server.
  226. The property is nil until the request completes. If there was a response
  227. then this property will be non-nil during the FBRequestHandler callback.
  228. */
  229. @property (nonatomic, retain, readonly) NSHTTPURLResponse *urlResponse;
  230. /*!
  231. @attribute beta true
  232. @abstract Set the automatic error handling behaviors.
  233. @discussion
  234. This must be set before any requests are added.
  235. When using retry behaviors, note the FBRequestConnection instance
  236. passed to the FBRequestHandler may be a different instance that the
  237. one the requests were originally started on.
  238. */
  239. @property (nonatomic, assign) FBRequestConnectionErrorBehavior errorBehavior;
  240. @property (nonatomic, assign) id<FBRequestConnectionDelegate> delegate;
  241. /*!
  242. @methodgroup Adding requests
  243. */
  244. /*!
  245. @method
  246. @abstract
  247. This method adds an <FBRequest> object to this connection.
  248. @discussion
  249. The completion handler is retained until the block is called upon the
  250. completion or cancellation of the connection.
  251. @param request A request to be included in the round-trip when start is called.
  252. @param handler A handler to call back when the round-trip completes or times out.
  253. The handler will be invoked on the main thread.
  254. */
  255. - (void)addRequest:(FBRequest *)request
  256. completionHandler:(FBRequestHandler)handler;
  257. /*!
  258. @method
  259. @abstract
  260. This method adds an <FBRequest> object to this connection.
  261. @discussion
  262. The completion handler is retained until the block is called upon the
  263. completion or cancellation of the connection. This request can be named
  264. to allow for using the request's response in a subsequent request.
  265. @param request A request to be included in the round-trip when start is called.
  266. @param handler A handler to call back when the round-trip completes or times out.
  267. The handler will be invoked on the main thread.
  268. @param name An optional name for this request. This can be used to feed
  269. the results of one request to the input of another <FBRequest> in the same
  270. `FBRequestConnection` as described in
  271. [Graph API Batch Requests]( https://developers.facebook.com/docs/reference/api/batch/ ).
  272. */
  273. - (void)addRequest:(FBRequest *)request
  274. completionHandler:(FBRequestHandler)handler
  275. batchEntryName:(NSString *)name;
  276. /*!
  277. @method
  278. @abstract
  279. This method adds an <FBRequest> object to this connection.
  280. @discussion
  281. The completion handler is retained until the block is called upon the
  282. completion or cancellation of the connection. This request can be named
  283. to allow for using the request's response in a subsequent request.
  284. @param request A request to be included in the round-trip when start is called.
  285. @param handler A handler to call back when the round-trip completes or times out.
  286. @param batchParameters The optional dictionary of parameters to include for this request
  287. as described in [Graph API Batch Requests]( https://developers.facebook.com/docs/reference/api/batch/ ).
  288. Examples include "depends_on", "name", or "omit_response_on_success".
  289. */
  290. - (void)addRequest:(FBRequest *)request
  291. completionHandler:(FBRequestHandler)handler
  292. batchParameters:(NSDictionary *)batchParameters;
  293. /*!
  294. @methodgroup Instance methods
  295. */
  296. /*!
  297. @method
  298. @abstract
  299. This method starts a connection with the server and is capable of handling all of the
  300. requests that were added to the connection.
  301. @discussion
  302. Errors are reported via the handler callback, even in cases where no
  303. communication is attempted by the implementation of `FBRequestConnection`. In
  304. such cases multiple error conditions may apply, and if so the following
  305. priority (highest to lowest) is used:
  306. - `FBRequestConnectionInvalidRequestKey` -- this error is reported when an
  307. <FBRequest> cannot be encoded for transmission.
  308. - `FBRequestConnectionInvalidBatchKey` -- this error is reported when any
  309. request in the connection cannot be encoded for transmission with the batch.
  310. In this scenario all requests fail.
  311. This method cannot be called twice for an `FBRequestConnection` instance.
  312. */
  313. - (void)start;
  314. /*!
  315. @method
  316. @abstract
  317. Signals that a connection should be logically terminated as the
  318. application is no longer interested in a response.
  319. @discussion
  320. Synchronously calls any handlers indicating the request was cancelled. Cancel
  321. does not guarantee that the request-related processing will cease. It
  322. does promise that all handlers will complete before the cancel returns. A call to
  323. cancel prior to a start implies a cancellation of all requests associated
  324. with the connection.
  325. */
  326. - (void)cancel;
  327. /*!
  328. @method
  329. @abstract
  330. Overrides the default version for a batch request
  331. @discussion
  332. The SDK automatically prepends a version part, such as "v2.0" to API paths in order to simplify API versioning
  333. for applications. If you want to override the version part while using batch requests on the connection, call
  334. this method to set the version for the batch request.
  335. @param version This is a string in the form @"v2.0" which will be used for the version part of an API path
  336. */
  337. - (void)overrideVersionPartWith:(NSString *)version;
  338. /*!
  339. @method
  340. @abstract
  341. Simple method to make a graph API request for user info (/me), creates an <FBRequest>
  342. then uses an <FBRequestConnection> object to start the connection with Facebook. The
  343. request uses the active session represented by `[FBSession activeSession]`.
  344. See <connectionWithSession:graphPath:parameters:HTTPMethod:completionHandler:>
  345. @param handler The handler block to call when the request completes with a success, error, or cancel action.
  346. */
  347. + (FBRequestConnection *)startForMeWithCompletionHandler:(FBRequestHandler)handler;
  348. /*!
  349. @method
  350. @abstract
  351. Simple method to make a graph API request for user friends (/me/friends), creates an <FBRequest>
  352. then uses an <FBRequestConnection> object to start the connection with Facebook. The
  353. request uses the active session represented by `[FBSession activeSession]`.
  354. See <connectionWithSession:graphPath:parameters:HTTPMethod:completionHandler:>
  355. @param handler The handler block to call when the request completes with a success, error, or cancel action.
  356. */
  357. + (FBRequestConnection *)startForMyFriendsWithCompletionHandler:(FBRequestHandler)handler;
  358. /*!
  359. @method
  360. @abstract
  361. Simple method to make a graph API post of a photo. The request
  362. uses the active session represented by `[FBSession activeSession]`.
  363. @param photo A `UIImage` for the photo to upload.
  364. @param handler The handler block to call when the request completes with a success, error, or cancel action.
  365. */
  366. + (FBRequestConnection *)startForUploadPhoto:(UIImage *)photo
  367. completionHandler:(FBRequestHandler)handler;
  368. /*!
  369. @method
  370. @abstract
  371. Simple method to make a graph API post of a status update. The request
  372. uses the active session represented by `[FBSession activeSession]`.
  373. @param message The message to post.
  374. @param handler The handler block to call when the request completes with a success, error, or cancel action.
  375. */
  376. + (FBRequestConnection *)startForPostStatusUpdate:(NSString *)message
  377. completionHandler:(FBRequestHandler)handler;
  378. /*!
  379. @method
  380. @abstract
  381. Simple method to make a graph API post of a status update. The request
  382. uses the active session represented by `[FBSession activeSession]`.
  383. @param message The message to post.
  384. @param place The place to checkin with, or nil. Place may be an fbid or a
  385. graph object representing a place.
  386. @param tags Array of friends to tag in the status update, each element
  387. may be an fbid or a graph object representing a user.
  388. @param handler The handler block to call when the request completes with a success, error, or cancel action.
  389. */
  390. + (FBRequestConnection *)startForPostStatusUpdate:(NSString *)message
  391. place:(id)place
  392. tags:(id<NSFastEnumeration>)tags
  393. completionHandler:(FBRequestHandler)handler;
  394. /*!
  395. @method
  396. @abstract
  397. Starts a request representing a Graph API call to the "search" endpoint
  398. for a given location using the active session.
  399. @discussion
  400. Simplifies starting a request to search for places near a coordinate.
  401. This method creates the necessary <FBRequest> object and initializes and
  402. starts an <FBRequestConnection> object. A successful Graph API call will
  403. return an array of <FBGraphPlace> objects representing the nearby locations.
  404. @param coordinate The search coordinates.
  405. @param radius The search radius in meters.
  406. @param limit The maxiumum number of results to return. It is
  407. possible to receive fewer than this because of the
  408. radius and because of server limits.
  409. @param searchText The text to use in the query to narrow the set of places
  410. returned.
  411. @param handler The handler block to call when the request completes with a success, error, or cancel action.
  412. */
  413. + (FBRequestConnection *)startForPlacesSearchAtCoordinate:(CLLocationCoordinate2D)coordinate
  414. radiusInMeters:(NSInteger)radius
  415. resultsLimit:(NSInteger)limit
  416. searchText:(NSString *)searchText
  417. completionHandler:(FBRequestHandler)handler;
  418. /*!
  419. @method
  420. @abstract
  421. Starts a request representing the Graph API call to retrieve a Custom Audience "third party ID" for the app's Facebook user.
  422. Callers will send this ID back to their own servers, collect up a set to create a Facebook Custom Audience with,
  423. and then use the resultant Custom Audience to target ads.
  424. @param session The FBSession to use to establish the user's identity for users logged into Facebook through this app.
  425. If `nil`, then the activeSession is used.
  426. @discussion
  427. This method will throw an exception if <[FBSettings defaultAppID]> is `nil`. The appID won't be nil when the pList
  428. includes the appID, or if it's explicitly set.
  429. The JSON in the request's response will include an "custom_audience_third_party_id" key/value pair, with the value being the ID retrieved.
  430. This ID is an encrypted encoding of the Facebook user's ID and the invoking Facebook app ID.
  431. Multiple calls with the same user will return different IDs, thus these IDs cannot be used to correlate behavior
  432. across devices or applications, and are only meaningful when sent back to Facebook for creating Custom Audiences.
  433. The ID retrieved represents the Facebook user identified in the following way: if the specified session (or activeSession if the specified
  434. session is `nil`) is open, the ID will represent the user associated with the activeSession; otherwise the ID will represent the user logged into the
  435. native Facebook app on the device. If there is no native Facebook app, no one is logged into it, or the user has opted out
  436. at the iOS level from ad tracking, then a `nil` ID will be returned.
  437. This method returns `nil` if either the user has opted-out (via iOS) from Ad Tracking, the app itself has limited event usage
  438. via the `[FBAppEvents setLimitEventUsage]` flag, or a specific Facebook user cannot be identified.
  439. @param handler The handler block to call when the request completes with a success, error, or cancel action.
  440. */
  441. + (FBRequestConnection *)startForCustomAudienceThirdPartyID:(FBSession *)session
  442. completionHandler:(FBRequestHandler)handler;
  443. /*!
  444. @method
  445. @abstract
  446. Simple method to make a graph API request, creates an <FBRequest> object for HTTP GET,
  447. then uses an <FBRequestConnection> object to start the connection with Facebook. The
  448. request uses the active session represented by `[FBSession activeSession]`.
  449. See <connectionWithSession:graphPath:parameters:HTTPMethod:completionHandler:>
  450. @param graphPath The Graph API endpoint to use for the request, for example "me".
  451. @param handler The handler block to call when the request completes with a success, error, or cancel action.
  452. */
  453. + (FBRequestConnection *)startWithGraphPath:(NSString *)graphPath
  454. completionHandler:(FBRequestHandler)handler;
  455. /*!
  456. @method
  457. @abstract
  458. Simple method to delete an object using the graph API, creates an <FBRequest> object for
  459. HTTP DELETE, then uses an <FBRequestConnection> object to start the connection with Facebook.
  460. The request uses the active session represented by `[FBSession activeSession]`.
  461. @param object The object to delete, may be an NSString or NSNumber representing an fbid or an NSDictionary with an id property
  462. @param handler The handler block to call when the request completes with a success, error, or cancel action.
  463. */
  464. + (FBRequestConnection *)startForDeleteObject:(id)object
  465. completionHandler:(FBRequestHandler)handler;
  466. /*!
  467. @method
  468. @abstract
  469. Simple method to post an object using the graph API, creates an <FBRequest> object for
  470. HTTP POST, then uses <FBRequestConnection> to start a connection with Facebook. The request uses
  471. the active session represented by `[FBSession activeSession]`.
  472. @param graphPath The Graph API endpoint to use for the request, for example "me".
  473. @param graphObject An object or open graph action to post.
  474. @param handler The handler block to call when the request completes with a success, error, or cancel action.
  475. @discussion This method is typically used for posting an open graph action. If you are only
  476. posting an open graph object (without an action), consider using `startForPostOpenGraphObject:completionHandler:`
  477. */
  478. + (FBRequestConnection *)startForPostWithGraphPath:(NSString *)graphPath
  479. graphObject:(id<FBGraphObject>)graphObject
  480. completionHandler:(FBRequestHandler)handler;
  481. /*!
  482. @method
  483. @abstract
  484. Creates an `FBRequest` object for a Graph API call, instantiate an
  485. <FBRequestConnection> object, add the request to the newly created
  486. connection and finally start the connection. Use this method for
  487. specifying the request parameters and HTTP Method. The request uses
  488. the active session represented by `[FBSession activeSession]`.
  489. @param graphPath The Graph API endpoint to use for the request, for example "me".
  490. @param parameters The parameters for the request. A value of nil sends only the automatically handled parameters, for example, the access token. The default is nil.
  491. @param HTTPMethod The HTTP method to use for the request. A nil value implies a GET.
  492. @param handler The handler block to call when the request completes with a success, error, or cancel action.
  493. */
  494. + (FBRequestConnection *)startWithGraphPath:(NSString *)graphPath
  495. parameters:(NSDictionary *)parameters
  496. HTTPMethod:(NSString *)HTTPMethod
  497. completionHandler:(FBRequestHandler)handler;
  498. /*!
  499. @method
  500. @abstract
  501. Creates an `FBRequest` for creating a user owned Open Graph object, instantiate a
  502. <FBRequestConnection> object, add the request to the newly created
  503. connection and finally start the connection. The request uses
  504. the active session represented by `[FBSession activeSession]`.
  505. @param object The Open Graph object to create. Some common expected fields include "title", "image", "url", etc.
  506. @param handler The handler block to call when the request completes with a success, error, or cancel action.
  507. */
  508. + (FBRequestConnection *)startForPostOpenGraphObject:(id<FBOpenGraphObject>)object
  509. completionHandler:(FBRequestHandler)handler;
  510. /*!
  511. @method
  512. @abstract
  513. Creates an `FBRequest` for creating a user owned Open Graph object, instantiate a
  514. <FBRequestConnection> object, add the request to the newly created
  515. connection and finally start the connection. The request uses
  516. the active session represented by `[FBSession activeSession]`.
  517. @param type The fully-specified Open Graph object type (e.g., my_app_namespace:my_object_name)
  518. @param title The title of the Open Graph object.
  519. @param image The link to an image to be associated with the Open Graph object.
  520. @param url The url to be associated with the Open Graph object.
  521. @param description The description for the object.
  522. @param objectProperties Any additional properties for the Open Graph object.
  523. @param handler The handler block to call when the request completes with a success, error, or cancel action.
  524. */
  525. + (FBRequestConnection *)startForPostOpenGraphObjectWithType:(NSString *)type
  526. title:(NSString *)title
  527. image:(id)image
  528. url:(id)url
  529. description:(NSString *)description
  530. objectProperties:(NSDictionary *)objectProperties
  531. completionHandler:(FBRequestHandler)handler;
  532. /*!
  533. @method
  534. @abstract
  535. Creates an `FBRequest` for updating a user owned Open Graph object, instantiate a
  536. <FBRequestConnection> object, add the request to the newly created
  537. connection and finally start the connection. The request uses
  538. the active session represented by `[FBSession activeSession]`.
  539. @param object The Open Graph object to update the existing object with.
  540. @param handler The handler block to call when the request completes with a success, error, or cancel action.
  541. */
  542. + (FBRequestConnection *)startForUpdateOpenGraphObject:(id<FBOpenGraphObject>)object
  543. completionHandler:(FBRequestHandler)handler;
  544. /*!
  545. @method
  546. @abstract
  547. Creates an `FBRequest` for updating a user owned Open Graph object, instantiate a
  548. <FBRequestConnection> object, add the request to the newly created
  549. connection and finally start the connection. The request uses
  550. the active session represented by `[FBSession activeSession]`.
  551. @param objectId The id of the Open Graph object to update.
  552. @param title The updated title of the Open Graph object.
  553. @param image The updated link to an image to be associated with the Open Graph object.
  554. @param url The updated url to be associated with the Open Graph object.
  555. @param description The object's description.
  556. @param objectProperties Any additional properties to update for the Open Graph object.
  557. @param handler The handler block to call when the request completes with a success, error, or cancel action.
  558. */
  559. + (FBRequestConnection *)startForUpdateOpenGraphObjectWithId:(id)objectId
  560. title:(NSString *)title
  561. image:(id)image
  562. url:(id)url
  563. description:(NSString *)description
  564. objectProperties:(NSDictionary *)objectProperties
  565. completionHandler:(FBRequestHandler)handler;
  566. /*!
  567. @method
  568. @abstract
  569. Starts a request connection to upload an image
  570. to create a staging resource. Staging resources allow you to post binary data
  571. such as images, in preparation for a post of an open graph object or action
  572. which references the image. The URI returned when uploading a staging resource
  573. may be passed as the value for the image property of an open graph object or action.
  574. @discussion
  575. This method simplifies the preparation of a Graph API call be creating the FBRequest
  576. object and starting the request connection with a single method
  577. @param image A `UIImage` for the image to upload.
  578. @param handler The handler block to call when the request completes.
  579. */
  580. + (FBRequestConnection *)startForUploadStagingResourceWithImage:(UIImage *)image
  581. completionHandler:(FBRequestHandler)handler;
  582. @end