### PHP SDK Example for Instagram Oembed Source: https://developers.facebook.com/docs/graph-api/reference/instagram-oembed Demonstrates how to make a GET request to the Instagram Oembed endpoint using the PHP SDK. Ensure you have the Facebook SDK installed and configured. ```php /* PHP SDK v5.0.0 */ /* make the API call */ try { // Returns a `Facebook\FacebookResponse` object $response = $fb->get( '/instagram_oembed', '{access-token}' ); } catch(Facebook\Exceptions\FacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(Facebook\Exceptions\FacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); /* handle the result */ ``` -------------------------------- ### Create Ad Set Source: https://developers.facebook.com/docs/graph-api/reference/ad-campaign This example demonstrates how to create an ad set with a daily budget for an App Installs campaign objective. It includes targeting specifications and other essential parameters. ```APIDOC ## POST /act_/adsets ### Description Creates an ad set for an ad campaign. This endpoint allows for detailed configuration of targeting, budget, optimization goals, and status. ### Method POST ### Endpoint https://graph.facebook.com/v25.0/act_/adsets ### Parameters #### Path Parameters - **AD_ACCOUNT_ID** (string) - Required - The ID of the ad account. #### Request Body - **name** (string) - Required - The name of the ad set. - **daily_budget** (number) - Required - The daily budget for the ad set in US Dollars. - **bid_amount** (number) - Optional - The bid amount for the ad set. - **billing_event** (string) - Required - The billing event for the ad set (e.g., "IMPRESSIONS", "CLICKS"). - **optimization_goal** (string) - Required - The optimization goal for the ad set (e.g., "APP_INSTALLS"). - **campaign_id** (string) - Required - The ID of the ad campaign to which this ad set belongs. - **promoted_object** (object) - Required - An object containing details about the promoted object, such as application ID and store URL. - **application_id** (string) - Required - The ID of the application being promoted. - **object_store_url** (string) - Required - The URL of the application in the app store. - **targeting** (object) - Required - An object specifying the targeting criteria for the ad set. - **device_platforms** (array) - Optional - Array of device platforms to target (e.g., ["mobile"]). - **facebook_positions** (array) - Optional - Array of Facebook placements to target (e.g., ["feed"]). - **geo_locations** (object) - Optional - Object specifying geographic targeting. - **countries** (array) - Optional - Array of country codes to target (e.g., ["US"]). - **publisher_platforms** (array) - Optional - Array of publisher platforms to target (e.g., ["facebook", "audience_network"]). - **user_os** (array) - Optional - Array of user operating systems to target (e.g., ["IOS"]). - **status** (string) - Required - The status of the ad set (e.g., "PAUSED"). - **access_token** (string) - Required - The user's access token. ### Request Example ```json { "name": "Mobile App Installs Ad Set", "daily_budget": 1000, "bid_amount": 2, "billing_event": "IMPRESSIONS", "optimization_goal": "APP_INSTALLS", "campaign_id": "", "promoted_object": { "application_id": "", "object_store_url": "" }, "targeting": { "device_platforms": [ "mobile" ], "facebook_positions": [ "feed" ], "geo_locations": { "countries": [ "US" ] }, "publisher_platforms": [ "facebook", "audience_network" ], "user_os": [ "IOS" ] }, "status": "PAUSED", "access_token": "" } ``` ### Response #### Success Response (200) Details of the created ad set, including its ID and status. #### Response Example ```json { "id": "", "name": "Mobile App Installs Ad Set", "status": "PAUSED" } ``` ``` -------------------------------- ### Get Started with Graph API Explorer Source: https://developers.facebook.com/docs/graph-api/common-scenarios Explore Graph API endpoints and run your first request using the Graph API Explorer tool. ```APIDOC ## Get Started with Graph API Explorer ### Description This guide helps you get started with the Graph API by using the Graph API Explorer tool to run your initial requests and understand the basic interactions. ### Method GET ### Endpoint /v25.0 ### Parameters #### Query Parameters - **access_token** (string) - Required - The access token for authentication. - **pretty** (boolean) - Optional - If true, returns a pretty-printed JSON response. ### Request Example ```json { "example": "GET /v25.0?access_token=YOUR_ACCESS_TOKEN&pretty=true" } ``` ### Response #### Success Response (200) - **data** (array) - An array of objects returned by the API. #### Response Example ```json { "example": { "data": [ { "id": "1234567890", "name": "Facebook User" } ] } } ``` ``` -------------------------------- ### Create Ad Set with Lifetime Budget Source: https://developers.facebook.com/docs/graph-api/reference/ad-campaign This example demonstrates how to create an ad set with a lifetime budget, including start and end times. Remember to substitute the placeholder values. ```bash curl -X POST \ -F 'name="My First Adset"' \ -F 'lifetime_budget=20000' \ -F 'start_time="2025-12-04T20:32:30-0800"' \ -F 'end_time="2025-12-14T20:32:30-0800"' \ -F 'campaign_id=""' \ -F 'bid_amount=100' \ -F 'billing_event="LINK_CLICKS"' \ -F 'optimization_goal="LINK_CLICKS"' \ -F 'targeting={ "facebook_positions": [ "feed" ], "geo_locations": { "countries": [ "US" ] }, "publisher_platforms": [ "facebook", "audience_network" ] }' \ -F 'status="PAUSED"' \ -F 'access_token=' \ https://graph.facebook.com/v25.0/act_/adsets ``` -------------------------------- ### Read Binary Transparency Proofs (PHP SDK) Source: https://developers.facebook.com/docs/graph-api/reference/binary_transparency_proofs This PHP SDK example shows how to make a GET request to the binary transparency proofs endpoint. Handle potential GraphResponseException and FacebookSDKException. ```php /* PHP SDK v5.0.0 */ /* make the API call */ try { // Returns a `Facebook\FacebookResponse` object $response = $fb->get( '/binary_transparency_proofs', '{access-token}' ); } catch(Facebook\Exceptions\FacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(Facebook\Exceptions\FacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); /* handle the result */ ``` -------------------------------- ### Read Reactions on a Post (JavaScript SDK) Source: https://developers.facebook.com/docs/graph-api/reference/object/reactions This JavaScript SDK example illustrates how to make a GET request to retrieve reactions for a post. It requires an access token and a callback function to process the response. ```javascript FB.api( '/your-post-id/reactions', 'GET', {}, function(response) { // Insert your code here } ); ``` -------------------------------- ### Create Ad Set using PHP SDK Source: https://developers.facebook.com/docs/graph-api/reference/ad-campaign This PHP SDK example demonstrates how to create an ad set. It includes error handling for Graph API and SDK-specific exceptions. Ensure you have the Facebook PHP SDK installed. ```php /* PHP SDK v5.0.0 */ /* make the API call */ try { // Returns a `Facebook\FacebookResponse` object $response = $fb->post( '/act_/adsets', array ( 'name' => 'My First Adset', 'lifetime_budget' => '20000', 'start_time' => '2026-06-13T17:29:35-0700', 'end_time' => '2026-06-23T17:29:35-0700', 'campaign_id' => '', 'bid_amount' => '100', 'billing_event' => 'LINK_CLICKS', 'optimization_goal' => 'LINK_CLICKS', 'targeting' => '{"facebook_positions":["feed"],"geo_locations":{"countries":["US"]},"publisher_platforms":["facebook","audience_network"]}', 'status' => 'PAUSED', ), '{access-token}' ); } catch(Facebook\Exceptions\FacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(Facebook\Exceptions\FacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); /* handle the result */ ``` -------------------------------- ### Read Binary Transparency Proofs (Android SDK) Source: https://developers.facebook.com/docs/graph-api/reference/binary_transparency_proofs This Android SDK example demonstrates making an asynchronous GET request for binary transparency proofs using GraphRequest. The result is handled in the onCompleted callback. ```java /* make the API call */ new GraphRequest( AccessToken.getCurrentAccessToken(), "/binary_transparency_proofs", null, HttpMethod.GET, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) { /* handle the result */ } } ).executeAsync(); ``` -------------------------------- ### Example Graph API Response for /me/feed Source: https://developers.facebook.com/docs/graph-api/guides/field-expansion This is an example response from a GET request to the /me/feed edge, showing paginated data and paging information. ```json { "data": [ { "created_time": "2021-04-30T01:37:07+0000", "message": "I'll never forget it has a head.", "id": "10211998223264288_10222340566616408" }, ... { "created_time": "2021-04-25T22:29:26+0000", "message": "Things you hear at my house: \"I accidentally made a cake.\"", "id": "10211998223264288_10222314489524497" } ], "paging": { "previous": "https://graph.facebook.com///feed?access_token=&pretty=0&__previous=1&since=1627322627&until&__paging_token=enc_AdB2fX...", "next": "https://graph.facebook.com///feed?access_token=&pretty=0&until=1619389766&since&__paging_token=enc_AdAamX...&__previous" } } ``` -------------------------------- ### iOS SDK Example for Instagram Oembed Source: https://developers.facebook.com/docs/graph-api/reference/instagram-oembed Demonstrates how to call the Instagram Oembed endpoint using the iOS SDK. This involves creating aFBSDKGraphRequest and starting the connection. ```objective-c /* make the API call */ FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/instagram_oembed" parameters:params HTTPMethod:@"GET"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Handle the result }]; ``` -------------------------------- ### Publish Post and Get Page Feed in One Batch Source: https://developers.facebook.com/docs/graph-api/batch-requests This example demonstrates publishing a post to a Page and then retrieving the Page's feed in a single batch request. Ensure you have the necessary publish permissions for the Page. ```curl curl "https://graph.facebook.com/PAGE-ID?batch= [ { "method":"POST", "relative_url":"PAGE-ID/feed", "body":"message=Test status update" }, { "method":"GET", "relative_url":"PAGE-ID/feed" } ] &access_token=ACCESS-TOKEN" ``` -------------------------------- ### Android SDK Example for Instagram Oembed Source: https://developers.facebook.com/docs/graph-api/reference/instagram-oembed Illustrates making a GET request to the Instagram Oembed endpoint using the Android SDK. This requires an AccessToken and a GraphRequest object. ```java /* make the API call */ new GraphRequest( AccessToken.getCurrentAccessToken(), "/instagram_oembed", null, HttpMethod.GET, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) { /* handle the result */ } } ).executeAsync(); ``` -------------------------------- ### Android SDK: Get App Information Source: https://developers.facebook.com/docs/graph-api/reference/application An example using the Android SDK to retrieve app details. This code should be placed within an Android Activity or Fragment and requires appropriate permissions and access token. ```Java /* make the API call */ new GraphRequest( AccessToken.getCurrentAccessToken(), "/{application-id}", null, HttpMethod.GET, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) { /* handle the result */ } } ).executeAsync(); ``` -------------------------------- ### Read iOS SKAdNetwork Conversion Config (iOS SDK) Source: https://developers.facebook.com/docs/graph-api/reference/application/ios_skadnetwork_conversion_config Example of making a GET request to the iOS SKAdNetwork conversion config endpoint using the iOS SDK. The result is handled in the completion handler. ```objective-c /* make the API call */ FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/{application-id}/ios_skadnetwork_conversion_config" parameters:params HTTPMethod:@"GET"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Handle the result }]; ``` -------------------------------- ### Read iOS SKAdNetwork Conversion Config (JavaScript SDK) Source: https://developers.facebook.com/docs/graph-api/reference/application/ios_skadnetwork_conversion_config Example of making a GET request to the iOS SKAdNetwork conversion config endpoint using the JavaScript SDK. Handles the API response. ```javascript /* make the API call */ FB.api( "/{application-id}/ios_skadnetwork_conversion_config", function (response) { if (response && !response.error) { /* handle the result */ } } ); ``` -------------------------------- ### PHP SDK: Get App Information Source: https://developers.facebook.com/docs/graph-api/reference/application Use the PHP SDK to make a GET request for application details. Ensure you have the Facebook SDK for PHP installed and configured. ```PHP /* PHP SDK v5.0.0 */ /* make the API call */ try { // Returns a `Facebook\FacebookResponse` object $response = $fb->get( '/{application-id}', '{access-token}' ); } catch(Facebook\Exceptions\FacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(Facebook\Exceptions\FacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); /* handle the result */ ``` -------------------------------- ### Download Ad Details Source: https://developers.facebook.com/docs/graph-api/reference/adgroup This example shows how to download details for an ad, including setting its status and redownloading options. ```curl curl -X POST \ -F 'name="My AdGroup with Redownload"' \ -F 'adset_id=""' \ -F 'creative={ "creative_id": "" }' \ -F 'redownload=1' \ -F 'status="PAUSED"' \ -F 'access_token=' \ https://graph.facebook.com/v25.0/act_/ads ``` -------------------------------- ### HTTP Request for Comments Source: https://developers.facebook.com/docs/graph-api/reference/object/comments Example of an HTTP GET request to retrieve comments with summary and toplevel filter. ```HTTP GET /v25.0/{object-id}/comments?summary=1&filter=toplevel HTTP/1.1 Host: graph.facebook.com ``` -------------------------------- ### Read Place Tag (HTTP) Source: https://developers.facebook.com/docs/graph-api/reference/place-tag Example of how to make an HTTP GET request to read a place tag. ```http GET /v25.0/{place-tag-id} HTTP/1.1 Host: graph.facebook.com ``` -------------------------------- ### Get Ad Group Details (HTTP) Source: https://developers.facebook.com/docs/graph-api/reference/adgroup Example HTTP request to retrieve the ID and name of an ad group. ```HTTP GET /v25.0//?fields=id%2Cname HTTP/1.1 Host: graph.facebook.com ``` -------------------------------- ### Create Ad Set using JavaScript SDK Source: https://developers.facebook.com/docs/graph-api/reference/ad-campaign This JavaScript SDK example shows how to create an ad set. The callback function handles the response, including potential errors. Ensure the Facebook JavaScript SDK is loaded. ```javascript /* make the API call */ FB.api( "/act_/adsets", "POST", { "name": "My First Adset", "lifetime_budget": "20000", "start_time": "2026-06-13T17:29:35-0700", "end_time": "2026-06-23T17:29:35-0700", "campaign_id": "", "bid_amount": "100", "billing_event": "LINK_CLICKS", "optimization_goal": "LINK_CLICKS", "targeting": "{\"facebook_positions\":[\"feed\"],\"geo_locations\":{\"countries\":[\"US\"],\"publisher_platforms\":[\"facebook\",\"audience_network\"]}}", "status": "PAUSED" }, function (response) { if (response && !response.error) { /* handle the result */ } } ); ``` -------------------------------- ### GET /me Source: https://developers.facebook.com/docs/graph-api/get-started This endpoint retrieves basic user information such as ID and name. It's the starting point for interacting with the Graph API. ```APIDOC ## GET /me ### Description Retrieves the user's ID and name from the Facebook Graph API. This is a fundamental request for identifying the user making the request. ### Method GET ### Endpoint /me ### Parameters #### Query Parameters - **fields** (string) - Optional - Specifies the fields to retrieve for the user node. Defaults to 'id,name'. ### Request Example ```json { "example": "GET /me?fields=id,name" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the user. - **name** (string) - The name of the user. #### Response Example ```json { "id": "1028223264288", "name": "John Doe" } ``` ``` -------------------------------- ### Read User Photos (JavaScript SDK) Source: https://developers.facebook.com/docs/graph-api/reference/user/photos Example of making a GET request to the user photos endpoint using the Facebook JavaScript SDK. ```JavaScript /* make the API call */ FB.api( "/{user-id}/photos", function (response) { if (response && !response.error) { /* handle the result */ } } ); ``` -------------------------------- ### Create Application Source: https://developers.facebook.com/docs/graph-api/reference/application Create a new application by posting to the client_apps edge. ```APIDOC ## Create Application ### Description Create a new application by making a POST request to the `client_apps` edge. ### Method POST ### Endpoint `/{business_id}/client_apps` ### Parameters #### Request Body - **mappings** (array) - Required - The event to UI component mappings of the app. - **method** (enum {INFERENCE, MANUAL, CONFIRMED_INFERENCE, BUTTON_INDEXING, UNKNOWN}) - Required - Method type. - **event_name** (string) - Required - The name of the event. - **event_type** (enum {CLICK, SELECTED, TEXT_CHANGED}) - Required - The type of event. - **app_version** (string) - Required - The version of the app. - **parameters** (array) - Optional - Additional parameters for the event. - **name** (string) - Required - Name of the parameter. - **path** (array) - Required - Path information for the parameter. - **class_name** (string) - Required - The class name. - **index** (int64) - Required - The index. - **id** (int64) - Optional - The ID. - **text** (string) - Optional - The text. - **tag** (string) - Optional - The tag. - **description** (string) - Optional - The description. - **hint** (string) - Optional - The hint. - **match_bitmask** (int64) - Optional - The match bitmask. - **component_id** (string) - Required - The component ID. - **path_type** (enum {ABSOLUTE, RELATIVE}) - Optional - Default value: "ABSOLUTE". The type of path. - **path** (array) - Required - Path information for the event. - **class_name** (string) - Required - The class name. - **index** (int64) - Required - The index. - **id** (int64) - Optional - The ID. - **text** (string) - Optional - The text. - **tag** (string) - Optional - The tag. - **description** (string) - Optional - The description. - **hint** (string) - Optional - The hint. - **match_bitmask** (int64) - Optional - The match bitmask. - **component_id** (string) - Required - The component ID. - **path_type** (enum {ABSOLUTE, RELATIVE}) - Optional - Default value: "ABSOLUTE". The type of path. - **screenshot_handle** (string) - Optional - Handle for the screenshot. - **dimensions** (array) - Optional - Dimensions of the component. - **top** (int64) - Required - The top coordinate. - **left** (int64) - Required - The left coordinate. - **width** (int64) - Required - The width. - **height** (int64) - Required - The height. - **activity_name** (string) - Optional - The name of the activity. - **mutation_method** (enum {REPLACE, ADD, DELETE}) - Required - Detailed mutation type. - **platform** (enum {ANDROID, IOS}) - Required - The platform of the app. - **post_method** (enum {EYMT, CODELESS}) - Optional - Default value: "CODELESS". Whether the API is called by codeless or EYMT. ### Return Type Struct { `num_updated`: int32, `num_invalid`: int32, } ### Error Codes - **105**: The number of parameters exceeded the maximum for this operation. ``` -------------------------------- ### Read User Photos (Graph API Explorer) Source: https://developers.facebook.com/docs/graph-api/reference/user/photos Example of making a GET request to the user photos endpoint using the Graph API Explorer. ```HTTP GET /v25.0/{user-id}/photos HTTP/1.1 Host: graph.facebook.com ``` -------------------------------- ### Create Ad Group using JavaScript SDK Source: https://developers.facebook.com/docs/graph-api/reference/adgroup This JavaScript SDK example shows how to create an ad group. The callback function handles the response, checking for errors. ```javascript /* make the API call */ FB.api( "/act_/ads", "POST", { "name": "My Ad", "adset_id": "", "creative": "{\"creative_id\":\"\"}", "status": "PAUSED" }, function (response) { if (response && !response.error) { /* handle the result */ } } ); ``` -------------------------------- ### Read Games IAPProduct - iOS SDK Source: https://developers.facebook.com/docs/graph-api/reference/games-iap-product Demonstrates how to get an in-app purchaseable product's information using the Facebook iOS SDK. This code snippet shows the setup for a `FBSDKGraphRequest` to perform a GET operation and handle the completion. ```Objective-C /* make the API call */ FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/{games-iap-product-id}" parameters:params HTTPMethod:@"GET"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Handle the result }]; ``` -------------------------------- ### Get a Message using PHP SDK Source: https://developers.facebook.com/docs/graph-api/reference/message Retrieve a message using the Facebook PHP SDK. This example shows basic error handling and how to access the response. ```php /* PHP SDK v5.0.0 */ /* make the API call */ try { // Returns a `Facebook\FacebookResponse` object $response = $fb->get( '/{message-id}', '{access-token}' ); } catch(Facebook\Exceptions\FacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(Facebook\Exceptions\FacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); /* handle the result */ ``` -------------------------------- ### Sample Batch Request with cURL Source: https://developers.facebook.com/docs/graph-api/batch-requests This example demonstrates fetching information about two Pages managed by your app using cURL. 'include_headers=false' is used to exclude header information for efficiency. ```bash curl -i -X POST 'https://graph.facebook.com/me?batch= [ { "method":"GET", "relative_url":"PAGE-A-ID" }, { "method":"GET", "relative_url":"PAGE-B-ID" } ] &include_headers=false // Included to remove header information &access_token=ACCESS-TOKEN' ``` -------------------------------- ### Read User Photos (Android SDK) Source: https://developers.facebook.com/docs/graph-api/reference/user/photos Example of making a GET request to the user photos endpoint using the Facebook Android SDK. Requires `user_photos` permission. ```Java /* make the API call */ new GraphRequest( AccessToken.getCurrentAccessToken(), "/{user-id}/photos", null, HttpMethod.GET, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) { /* handle the result */ } } ).executeAsync(); ``` -------------------------------- ### Read User Photos (PHP SDK) Source: https://developers.facebook.com/docs/graph-api/reference/user/photos Example of making a GET request to the user photos endpoint using the Facebook PHP SDK. Ensure you have the `user_photos` permission. ```PHP /* PHP SDK v5.0.0 */ /* make the API call */ try { // Returns a `Facebook\FacebookResponse` object $response = $fb->get( '/{user-id}/photos', '{access-token}' ); } catch(Facebook\Exceptions\FacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(Facebook\Exceptions\FacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); /* handle the result */ ``` -------------------------------- ### Create Ad Group using PHP SDK Source: https://developers.facebook.com/docs/graph-api/reference/adgroup This PHP SDK example demonstrates how to create an ad group. It includes error handling for both Graph API and SDK-specific exceptions. ```php /* PHP SDK v5.0.0 */ /* make the API call */ try { // Returns a `Facebook\FacebookResponse` object $response = $fb->post( '/act_/ads', array ( 'name' => 'My Ad', 'adset_id' => '', 'creative' => '{"creative_id":""}', 'status' => 'PAUSED', ), '{access-token}' ); } catch(Facebook\Exceptions\FacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(Facebook\Exceptions\FacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); /* handle the result */ ``` -------------------------------- ### HTTP Request for User Data Source: https://developers.facebook.com/docs/graph-api/reference/user Basic HTTP GET request structure to retrieve user data from the Graph API. This is a foundational example for understanding API calls. ```http GET /v25.0/{person-id}/ HTTP/1.1 Host: graph.facebook.com ``` -------------------------------- ### Create Ad Set using Android SDK Source: https://developers.facebook.com/docs/graph-api/reference/ad-campaign This Android SDK example demonstrates creating an ad set. It uses `GraphRequest` and requires an `AccessToken`. The `onCompleted` method handles the API response. ```java Bundle params = new Bundle(); params.putString("name", "My First Adset"); params.putString("lifetime_budget", "20000"); params.putString("start_time", "2026-06-13T17:29:35-0700"); params.putString("end_time", "2026-06-23T17:29:35-0700"); params.putString("campaign_id", ""); params.putString("bid_amount", "100"); params.putString("billing_event", "LINK_CLICKS"); params.putString("optimization_goal", "LINK_CLICKS"); params.putString("targeting", "{\"facebook_positions\":[\"feed\"],\"geo_locations\":{\"countries\":[\"US\"],\"publisher_platforms\":[\"facebook\",\"audience_network\"]}}"); params.putString("status", "PAUSED"); /* make the API call */ new GraphRequest( AccessToken.getCurrentAccessToken(), "/act_/adsets", params, HttpMethod.POST, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) { /* handle the result */ } } ).executeAsync(); ``` -------------------------------- ### Sample X-App-Usage Header Source: https://developers.facebook.com/docs/graph-api/overview/rate-limiting This header provides insights into the current usage of API calls, total time, and total CPU time relative to the established limits. It helps developers monitor their application's proximity to throttling thresholds. ```json { "call_count": 28, //Percentage of calls made "total_time": 25, //Percentage of total time "total_cputime": 25 //Percentage of total CPU time } ``` -------------------------------- ### Read Binary Transparency Proofs (iOS SDK) Source: https://developers.facebook.com/docs/graph-api/reference/binary_transparency_proofs This iOS SDK snippet shows how to initiate a GET request for binary transparency proofs usingFBSDKGraphRequest. The result and any errors are handled in the startWithCompletionHandler block. ```objective-c /* make the API call */ FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/binary_transparency_proofs" parameters:params HTTPMethod:@"GET"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Handle the result }]; ``` -------------------------------- ### Read Upcoming Change (iOS SDK) Source: https://developers.facebook.com/docs/graph-api/reference/page-upcoming-change Use the iOS SDK to make a GET request for page upcoming change details. This involves creating and starting a GraphRequest. ```Objective-C /* make the API call */ FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/{page-upcoming-change-id}" parameters:params HTTPMethod:@"GET"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Handle the result }]; ``` -------------------------------- ### POST Request Example Source: https://developers.facebook.com/docs/graph-api/reference/object/private_replies This is an example of a POST request to the private_replies edge. ```HTTP POST /v25.0/{object-id}/private_replies HTTP/1.1 Host: graph.facebook.com ``` -------------------------------- ### Read Binary Transparency Proofs (HTTP) Source: https://developers.facebook.com/docs/graph-api/reference/binary_transparency_proofs Use this HTTP request to retrieve binary transparency proofs. Ensure you include your access token. ```http GET /v25.0/binary_transparency_proofs HTTP/1.1 Host: graph.facebook.com ``` -------------------------------- ### Get Comments using Android SDK Source: https://developers.facebook.com/docs/graph-api/reference/object/comments This example demonstrates fetching comments for an object via the Graph API using the Android SDK. A `GraphRequest` is created and executed asynchronously. ```java /* make the API call */ new GraphRequest( AccessToken.getCurrentAccessToken(), "/{object-id}/comments", null, HttpMethod.GET, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) { /* handle the result */ } } ).executeAsync(); ``` -------------------------------- ### Create Ad and Get Details in One Batch Source: https://developers.facebook.com/docs/graph-api/batch-requests This snippet shows how to create a new ad for a campaign and then fetch its details within a single batch request. Note the URL encoding required for the 'body' parameter. ```curl curl \ -F 'access_token=...' \ -F 'batch=[ { "method":"POST", "name":"create-ad", "relative_url":"11077200629332/ads", "body":"ads=%5B%7B%22name%22%3A%22test_ad%22%2C%22billing_entity_id%22%3A111200774273%7D%5D" }, { "method":"GET", "relative_url":"?ids={result=create-ad:$.data.*.id}" } ]' \ https://graph.facebook.com ``` -------------------------------- ### Get Comments using PHP SDK Source: https://developers.facebook.com/docs/graph-api/reference/object/comments This example demonstrates how to fetch comments for an object using the Facebook PHP SDK. It includes error handling for API and SDK exceptions. ```php /* PHP SDK v5.0.0 */ /* make the API call */ try { // Returns a `Facebook\FacebookResponse` object $response = $fb->get( '/{object-id}/comments', '{access-token}' ); } catch(Facebook\Exceptions\FacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(Facebook\Exceptions\FacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); /* handle the result */ ``` -------------------------------- ### Read User Photos (iOS SDK) Source: https://developers.facebook.com/docs/graph-api/reference/user/photos Example of making a GET request to the user photos endpoint using the Facebook iOS SDK. Ensure the `user_photos` permission is granted. ```Objective-C /* make the API call */ FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/{user-id}/photos" parameters:params HTTPMethod:@"GET"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Handle the result }]; ``` -------------------------------- ### Read User Data with JavaScript SDK Source: https://developers.facebook.com/docs/graph-api/reference/user This example shows how to fetch user data using the Facebook JavaScript SDK. Ensure you have initialized the SDK and obtained an access token. ```javascript /* make the API call */ FB.api( "/{person-id}/", function (response) { if (response && !response.error) { /* handle the result */ } } ); ``` -------------------------------- ### Read Privacy Info with Android SDK Source: https://developers.facebook.com/docs/graph-api/reference/privacy This Android SDK example demonstrates making a Graph API request to get privacy details. A callback is used to process the GraphResponse. ```Java /* make the API call */ new GraphRequest( AccessToken.getCurrentAccessToken(), "...?fields={fieldname_of_type_Privacy}", null, HttpMethod.GET, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) { /* handle the result */ } } ).executeAsync(); ``` -------------------------------- ### Create Ad Set with Daily Budget Source: https://developers.facebook.com/docs/graph-api/reference/ad-campaign Use this snippet to create a new ad set with a specified daily budget. Ensure you replace placeholders like ``, ``, and `` with your actual values. ```bash curl -X POST \ -F 'name="My Reach Ad Set"' \ -F 'optimization_goal="REACH"' \ -F 'billing_event="IMPRESSIONS"' \ -F 'bid_amount=2' \ -F 'daily_budget=1000' \ -F 'campaign_id=""' \ -F 'targeting={ "geo_locations": { "countries": [ "US" ] }, "facebook_positions": [ "feed" ] }' \ -F 'status="PAUSED"' \ -F 'promoted_object={ "page_id": "" }' \ -F 'access_token=' \ https://graph.facebook.com/v25.0/act_/adsets ``` -------------------------------- ### Read Upcoming Change (Android SDK) Source: https://developers.facebook.com/docs/graph-api/reference/page-upcoming-change Use the Android SDK to make a GET request for page upcoming change details. Ensure you have a valid AccessToken and GraphRequest setup. ```Java /* make the API call */ new GraphRequest( AccessToken.getCurrentAccessToken(), "/{page-upcoming-change-id}", null, HttpMethod.GET, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) { /* handle the result */ } } ).executeAsync(); ``` -------------------------------- ### Read Binary Transparency Artifacts (PHP SDK) Source: https://developers.facebook.com/docs/graph-api/reference/binary_transparency_artifacts Use the PHP SDK to make a GET request for binary transparency artifacts. Ensure you have a valid access token and handle potential Graph API or SDK exceptions. ```PHP /* PHP SDK v5.0.0 */ /* make the API call */ try { // Returns a `Facebook\FacebookResponse` object $response = $fb->get( '/binary_transparency_artifacts', '{access-token}' ); } catch(Facebook\Exceptions\FacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(Facebook\Exceptions\FacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); /* handle the result */ ``` -------------------------------- ### Create Ad Set with App Installs Objective Source: https://developers.facebook.com/docs/graph-api/reference/ad-campaign Use this cURL command to create a new ad set for mobile app installs. Ensure you replace placeholders like ``, ``, ``, ``, and `` with your actual values. The ad set is initially paused. ```curl curl -X POST \ -F 'name="Mobile App Installs Ad Set"' \ -F 'daily_budget=1000' \ -F 'bid_amount=2' \ -F 'billing_event="IMPRESSIONS"' \ -F 'optimization_goal="APP_INSTALLS"' \ -F 'campaign_id=""' \ -F 'promoted_object={ "application_id": "", "object_store_url": "" }' \ -F 'targeting={ "device_platforms": [ "mobile" ], "facebook_positions": [ "feed" ], "geo_locations": { "countries": [ "US" ] }, "publisher_platforms": [ "facebook", "audience_network" ], "user_os": [ "IOS" ] }' \ -F 'status="PAUSED"' \ -F 'access_token=' \ https://graph.facebook.com/v25.0/act_/adsets ``` -------------------------------- ### Read Canvas Details (PHP SDK) Source: https://developers.facebook.com/docs/graph-api/reference/canvas This PHP SDK snippet demonstrates how to make a GET request to retrieve canvas details. Ensure you have the Facebook SDK for PHP installed and configured. ```php /* PHP SDK v5.0.0 */ /* make the API call */ try { // Returns a `Facebook\FacebookResponse` object $response = $fb->get( '/{canvas-id}', '{access-token}' ); } catch(Facebook\Exceptions\FacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(Facebook\Exceptions\FacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); /* handle the result */ ``` -------------------------------- ### Read Binary Transparency Proofs (JavaScript SDK) Source: https://developers.facebook.com/docs/graph-api/reference/binary_transparency_proofs Use the FB.api method in the JavaScript SDK to fetch binary transparency proofs. Ensure you handle the response object for errors. ```javascript /* make the API call */ FB.api( "/binary_transparency_proofs", function (response) { if (response && !response.error) { /* handle the result */ } } ); ``` -------------------------------- ### Create Ad Set using iOS SDK Source: https://developers.facebook.com/docs/graph-api/reference/ad-campaign This iOS SDK example shows how to create an ad set using `FBSDKGraphRequest`. The completion handler processes the result or error. Ensure you have the Facebook SDK for iOS integrated. ```objective-c NSDictionary *params = @{ @"name": @"My First Adset", @"lifetime_budget": @"20000", @"start_time": @"2026-06-13T17:29:35-0700", @"end_time": @"2026-06-23T17:29:35-0700", @"campaign_id": @"", @"bid_amount": @"100", @"billing_event": @"LINK_CLICKS", @"optimization_goal": @"LINK_CLICKS", @"targeting": @"{\"facebook_positions\":[\"feed\"],\"geo_locations\":{\"countries\":[\"US\"],\"publisher_platforms\":[\"facebook\",\"audience_network\"]}}", @"status": @"PAUSED", }; /* make the API call */ FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/act_/adsets" parameters:params HTTPMethod:@"POST"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Handle the result }]; ``` -------------------------------- ### Binary Transparency Proofs Source: https://developers.facebook.com/docs/graph-api/reference Retrieves binary transparency proofs. ```APIDOC ## Binary Transparency Proofs ### Description Returns binary transparency proofs. ### Method GET ### Endpoint /binary_transparency_proofs ``` -------------------------------- ### Read Event Data using Android SDK Source: https://developers.facebook.com/docs/graph-api/reference/event Fetch event details with the Facebook Android SDK. This example uses `GraphRequest` to make a GET request and defines a callback for handling the response. ```java /* make the API call */ new GraphRequest( AccessToken.getCurrentAccessToken(), "/{event-id}", null, HttpMethod.GET, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) { /* handle the result */ } } ).executeAsync(); ``` -------------------------------- ### Publish Like using PHP SDK Source: https://developers.facebook.com/docs/graph-api/reference/object/likes Use the PHP SDK to publish a like to an object. Ensure you have the necessary permissions and that the object has not already been liked by the Page. ```php /* PHP SDK v5.0.0 */ /* make the API call */ try { // Returns a `Facebook\FacebookResponse` object $response = $fb->post( '/{object-id}/likes', array (), '{access-token}' ); } catch(Facebook\Exceptions\FacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(Facebook\Exceptions\FacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); /* handle the result */ ``` -------------------------------- ### Reading Binary Transparency Proofs Source: https://developers.facebook.com/docs/graph-api/reference/binary_transparency_proofs This endpoint allows you to retrieve binary transparency proofs. It supports query parameters for filtering and pagination. ```APIDOC ## GET /v25.0/binary_transparency_proofs ### Description Retrieves a list of binary transparency proofs. ### Method GET ### Endpoint /v25.0/binary_transparency_proofs ### Parameters #### Query Parameters - **maxEpoch** (int64) - Optional - The maximum epoch to retrieve proofs for. - **maxResults** (int64) - Optional - The maximum number of results to return. - **namespaceName** (string) - Required - The namespace for which to retrieve proofs. ### Fields Reading from this edge will return a JSON formatted result with `data` and `paging` keys. #### `data` A list of BinaryTransparencyCloudflareProof nodes. #### `paging` For more details about pagination, see the Graph API guide. ### Request Example ```json { "example": "GET /v25.0/binary_transparency_proofs?namespaceName=example.com&maxResults=10" } ``` ### Response #### Success Response (200) - **data** (list) - A list of BinaryTransparencyCloudflareProof nodes. - **paging** (object) - Pagination information. #### Response Example ```json { "data": [], "paging": {} } ``` ### Error Codes - **2717**: Invalid namespace ```