iOS SDK Version

FBSDKGraphRequest

@interfaceFBSDKGraphRequest:NSObject
Represents a request to the Facebook Graph API.
FBSDKGraphRequest encapsulates the components of a request (the Graph API path, the parameters, error recovery behavior) and should be used in conjunction with FBSDKGraphRequestConnection to issue the request.
Nearly all Graph APIs require an access token. Unless specified, the [FBSDKAccessToken currentAccessToken] is used. Therefore, most requests will require login first (see FBSDKLoginManager in FBSDKLoginKit.framework).
A - start method is provided for convenience for single requests.
By default, FBSDKGraphRequest will attempt to recover any errors returned from Facebook. You can disable this via disableErrorRecovery:.
See
FBSDKGraphErrorRecoveryProcessor
  • Unavailable
    Undocumented

    Declaration

    Objective-C
    -(instancetype)initNS_UNAVAILABLE;
  • Unavailable
    Undocumented

    Declaration

    Objective-C
    +(instancetype)newNS_UNAVAILABLE;
  • Initializes a new instance that use use [FBSDKAccessToken currentAccessToken].

    Declaration

    Objective-C
    -(nonnullinstancetype)initWithGraphPath:(nonnullNSString*)graphPath;
    Swift
    convenienceinit(graphPath:String)

    Parameters

    graphPath
    the graph path (e.g., @“me”).
  • Initializes a new instance that use use [FBSDKAccessToken currentAccessToken].

    Declaration

    Objective-C
    -(nonnullinstancetype)initWithGraphPath:(nonnullNSString*)graphPathHTTPMethod:(nonnullFBSDKHTTPMethod)method;
    Swift
    convenienceinit(graphPath:String,httpMethodmethod:HTTPMethod)

    Parameters

    graphPath
    the graph path (e.g., @“me”).
    method
    the HTTP method. Empty String defaults to @“GET”.
  • Initializes a new instance that use use [FBSDKAccessToken currentAccessToken].

    Declaration

    Objective-C
    -(nonnullinstancetype)initWithGraphPath:(nonnullNSString*)graphPathparameters:(nonnullNSDictionary<NSString*,id>*)parameters;
    Swift
    convenienceinit(graphPath:String,parameters:[String:Any])

    Parameters

    graphPath
    the graph path (e.g., @“me”).
    parameters
    the optional parameters dictionary.
  • Initializes a new instance that use use [FBSDKAccessToken currentAccessToken].

    Declaration

    Objective-C
    -(nonnullinstancetype)initWithGraphPath:(nonnullNSString*)graphPathparameters:(nonnullNSDictionary<NSString*,id>*)parametersHTTPMethod:(nonnullFBSDKHTTPMethod)method;
    Swift
    convenienceinit(graphPath:String,parameters:[String:Any],httpMethodmethod:HTTPMethod)

    Parameters

    graphPath
    the graph path (e.g., @“me”).
    parameters
    the optional parameters dictionary.
    method
    the HTTP method. Empty String defaults to @“GET”.
  • Initializes a new instance.

    Declaration

    Objective-C
    -(nonnullinstancetype)initWithGraphPath:(nonnullNSString*)graphPathparameters:(nonnullNSDictionary<NSString*,id>*)parameterstokenString:(nullableNSString*)tokenStringversion:(nullableNSString*)versionHTTPMethod:(nonnullFBSDKHTTPMethod)method;
    Swift
    init(graphPath:String,parameters:[String:Any],tokenString:String?,version:String?,httpMethodmethod:HTTPMethod)

    Parameters

    graphPath
    the graph path (e.g., @“me”).
    parameters
    the optional parameters dictionary.
    tokenString
    the token string to use. Specifying nil will cause no token to be used.
    version
    the optional Graph API version (e.g., @“v2.0”). nil defaults to [FBSDKSettings graphAPIVersion].
    method
    the HTTP method. Empty String defaults to @“GET”.
  • The request parameters.

    Declaration

    Objective-C
    @property(nonatomic,copy,readwrite)NSDictionary<NSString*,id>*_Nonnullparameters;
    Swift
    varparameters:[String:Any]{getset}
  • The access token string used by the request.

    Declaration

    Objective-C
    @property(nonatomic,copy,readonly,nullable)NSString*tokenString;
    Swift
    vartokenString:String?{get}
  • The Graph API endpoint to use for the request, for example “me”.

    Declaration

    Objective-C
    @property(nonatomic,copy,readonly)NSString*_NonnullgraphPath;
    Swift
    vargraphPath:String{get}
  • The HTTPMethod to use for the request, for example “GET” or “POST”.

    Declaration

    Objective-C
    @property(nonatomic,copy,readonly)FBSDKHTTPMethod_NonnullHTTPMethod;
    Swift
    varhttpMethod:HTTPMethod{get}
  • The Graph API version to use (e.g., “v2.0”)

    Declaration

    Objective-C
    @property(nonatomic,copy,readonly)NSString*_Nonnullversion;
    Swift
    varversion:String{get}
  • If set, disables the automatic error recovery mechanism.
    By default, non-batched FBSDKGraphRequest instances will automatically try to recover from errors by constructing a FBSDKGraphErrorRecoveryProcessor instance that re-issues the request on successful recoveries. The re-issued request will call the same handler as the receiver but may occur with a different FBSDKGraphRequestConnection instance.
    This will override [FBSDKSettings setGraphErrorRecoveryDisabled:].

    Declaration

    Objective-C
    -(void)setGraphErrorRecoveryDisabled:(BOOL)disable;
    Swift
    funcsetGraphErrorRecovery(disableddisable:Bool)

    Parameters

    disable
    whether to disable the automatic error recovery mechanism
  • Starts a connection to the Graph API.

    Declaration

    Objective-C
    -(nonnullFBSDKGraphRequestConnection*)startWithCompletionHandler:(nullableFBSDKGraphRequestBlock)handler;
    Swift
    funcstart(completionHandlerhandler:GraphRequestBlock?=nil)->GraphRequestConnection

    Parameters

    handler
    The handler block to call when the request completes.