Facebook Developers
DocsToolsSupportNewsApps
Log In
  • Social Plugins
  • Facebook Login
  • Open Graph
  • Facebook APIs
  • Games
  • Media
  • Payments
  • App Center
  • Promote Your App
  • iOS
  • Android
  • Web
    • Getting Started
    • JavaScript SDK
    • PHP SDK
    • More SDKs
    • Facebook for WordPress
  • Technology Partners
  • Facebook Object
    • api
    • getAccessToken
    • getApiSecret
    • getAppId
    • getLoginStatusUrl
    • getLoginUrl
    • getLogoutUrl
    • getSignedRequest
    • getUser
    • setAccessToken
    • setApiSecret
    • setAppId
    • setFileUploadSupport
    • useFileUploadSupport
  • FacebookApiException
    • getResult
    • getType

api

Web › PHP SDK › api

Facebook::api(...)

This method can call a Facebook Graph API method or an FQL query depending on the parameters passed in.

To call a Graph API method, pass in the path as the first parameter; to run FQL queries pass in the array of parameters required for the API call, as described below.

Parameters

Graph API Methods

To call a Graph API method, pass in the endpoint path you wish to retrieve as the first parameter, and other optional parameters as necessary:

$ret = $facebook->api($path, $method, $params);
Name Description
path The Graph API path for the request, e.g. "/me" for the logged in user's profile.
method (optional) Specify the HTTP method for this request: 'GET', 'POST', or 'DELETE'.
params (optional) Parameters specific to the particular Graph API method you are calling. Passed in as an associative array of 'name' => 'value' pairs.

FQL Queries

To run an FQL query, pass the parameters in as an array, with the 'method' property set to 'fql.query':

$ret = $facebook->api( array(
                         'method' => 'fql.query',
                         'query' => 'SELECT . . . ',
                     ));

Related How-Tos

  • Get the User's profile via the Graph API
  • Get the User's name using FQL
  • Post a link using the Graph API
  • Upload a photo to a User's profile
Updated 31 minutes ago
Facebook © 2013 · English (US)
AboutAdvertisingCareersPlatform PoliciesPrivacy Policy