### Add Feeling or Activity to Page Post (iOS SDK) Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Use the iOS SDK to add a feeling or activity to a page post. This example shows how to create and start a Graph API request. ```objective-c NSDictionary *params = @{ @"message": @"This is a test activity", @"og_action_type_id": @"383634835006146", @"og_object_id": @"136050896551329", @"og_icon_id": @"609297155780549", }; /* make the API call */ FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/page-id/feed" parameters:params HTTPMethod:@"POST"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Handle the result }]; ``` -------------------------------- ### Publish a Page Post using Objective-C SDK Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Use the Objective-C SDK to construct and start a POST request for publishing to the Page Feed. Handle the response in the completion handler. ```Objective-C FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/{your-page-id}/feed" parameters:@{ @"message": @"Become a Facebook developer!",@"link": @"https://developers.facebook.com",@"published": @"1",@"call_to_action": @"{\"type\":\"SIGN_UP\",\"value\":{\"link\":\"https://developers.facebook.com\"}}",} HTTPMethod:@"POST"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Insert your code here }]; ``` -------------------------------- ### Read Page Feed - PHP SDK Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Example of making a GET request to the Page Feed endpoint using the PHP SDK. Includes error handling for Graph API and SDK exceptions. ```php /* PHP SDK v5.0.0 */ /* make the API call */ try { // Returns a `Facebook\FacebookResponse` object $response = $fb->get( '/{page-id}/feed', '{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 */ ``` -------------------------------- ### Add Feeling or Activity to Page Post (Android SDK) Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Use the Android SDK to add a feeling or activity to a page post. This example demonstrates constructing the parameters and executing the request. ```java Bundle params = new Bundle(); params.putString("message", "This is a test activity"); params.putString("og_action_type_id", "383634835006146"); params.putString("og_object_id", "136050896551329"); params.putString("og_icon_id", "609297155780549"); /* make the API call */ new GraphRequest( AccessToken.getCurrentAccessToken(), "/page-id/feed", params, HttpMethod.POST, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) { /* handle the result */ } } ).executeAsync(); ``` -------------------------------- ### Publish a Page Post using PHP SDK Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Use the PHP SDK to send a POST request to the Page Feed. This example includes basic error handling for Graph API and SDK exceptions. ```PHP try { // Returns a `FacebookFacebookResponse` object $response = $fb->post( '/{your-page-id}/feed', array ( 'message' => 'Become a Facebook developer!', 'link' => 'https://developers.facebook.com', 'published' => '1', 'call_to_action' => '{"type":"SIGN_UP","value":{"link":"https://developers.facebook.com"}}' ), '{access-token}' ); } catch(FacebookExceptionsFacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(FacebookExceptionsFacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); ``` -------------------------------- ### Link Page Post with Call to Action Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Enhance link Page posts with call to action buttons to guide user interaction. ```APIDOC ## Link Page Post with Call to Action ### Description Allows adding a Call to Action button to link Page posts. ### Parameters #### Request Body - **call_to_action** (object) - Optional - Object that specifies a Call to Action button. - **type** (string) - Required - Determines the call to action button text. Allowed values include `BOOK_TRAVEL`, `BUY_NOW`, `CALL_NOW`, `DOWNLOAD`, `GET_DIRECTIONS`, `GET_QUOTE`, `INSTALL_APP`, `INSTALL_MOBILE_APP`, `LEARN_MORE`, `LIKE_PAGE`, `LISTEN_MUSIC`, `MESSAGE_PAGE`, `NO_BUTTON`, `OPEN_LINK`, `PLAY_GAME`, `SHOP_NOW`, `SIGN_UP`, `SUBSCRIBE`, `USE_APP`, `USE_MOBILE_APP`, `WATCH_MORE`, `WATCH_VIDEO`. - **link** (string) - Required if `type` is `GET_DIRECTIONS` - The URL for the call to action. Must specify coordinates on the `link` field for `GET_DIRECTIONS`. ### Request Example ```json { "message": "Check out our new product!", "link": "https://www.example.com", "call_to_action": { "type": "SHOP_NOW", "link": "https://www.example.com/shop" } } ``` ``` -------------------------------- ### Read Page Feed - Android SDK Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed An example of fetching the Page Feed using the Android SDK's GraphRequest. The `onCompleted` method handles the response or any errors. ```java /* make the API call */ new GraphRequest( AccessToken.getCurrentAccessToken(), "/{page-id}/feed", null, HttpMethod.GET, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) { /* handle the result */ } } ).executeAsync(); ``` -------------------------------- ### GET /feed - Check Promotion Eligibility Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Retrieves a list of posts from a page's feed and indicates whether each post is eligible for promotion. It also provides a `promotable_id` which must be used when creating ads for the post. If a post is not eligible, the `video_buying_eligibility` field will contain a list of reasons. ```APIDOC ## GET /feed ### Description Retrieves posts from a page's feed and checks their eligibility for promotion. Returns `promotable_id` for ad creation and `video_buying_eligibility` with reasons if not eligible. ### Method GET ### Endpoint `/{your-page-id}/feed` ### Query Parameters - **fields** (string) - Required - Comma-separated list of fields to retrieve. Must include `is_eligible_for_promotion` and `promotable_id`. - **access_token** (string) - Required - A valid Page access token. ### Request Example ```bash curl -i -X GET \ "https://graph.facebook.com/{your-page-id}/feed ?fields=is_eligible_for_promotion,promotable_id &access_token={your-page-access-token}" ``` ### Response #### Success Response (200) - **data** (array) - A list of post objects. - **is_eligible_for_promotion** (boolean) - Indicates if the post can be promoted. - **promotable_id** (string) - The ID to use when creating ads for the post. - **id** (string) - The post ID. - **video_buying_eligibility** (array) - If `is_eligible_for_promotion` is false, this array contains reasons why the post cannot be promoted. #### Response Example ```json { "data": [ { "is_eligible_for_promotion": true, "promotable_id": "1353269864728879_1943344825721377", "id": "1353269864728879_1943344825721377" }, { "is_eligible_for_promotion": false, "promotable_id": "1353269864728879_1942095249179668", "id": "1353269864728879_1942095249179668", "video_buying_eligibility": [ "VIDEO_IS_TOO_LONG" ] } ] } ``` ``` -------------------------------- ### Post to Facebook Page Feed using JavaScript SDK Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed This JavaScript SDK example shows how to post a message to a Facebook Page's feed. It includes a callback function to handle the API response. ```javascript /* make the API call */ FB.api( "/{page-id}/feed", "POST", { "message": "This is a test message" }, function (response) { if (response && !response.error) { /* handle the result */ } } ); ``` -------------------------------- ### Post to Facebook Page Feed using PHP SDK Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed This PHP SDK example demonstrates how to post a message to a Facebook Page's feed. It includes error handling for Graph API and SDK exceptions. ```php /* PHP SDK v5.0.0 */ /* make the API call */ try { // Returns a `Facebook\FacebookResponse` object $response = $fb->post( '/{page-id}/feed', array ( 'message' => 'This is a test message', ), '{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 */ ``` -------------------------------- ### Get Unpublished Page Posts using PHP SDK Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed This PHP SDK example shows how to retrieve unpublished Page posts, specifying the 'is_published' field. Ensure you have the Facebook PHP SDK installed and configured with your access token. ```php try { // Returns a `FacebookFacebookResponse` object $response = $fb->get( '/{page-id}/feed?fields=is_published', '{access-token}' ); } catch(FacebookExceptionsFacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(FacebookExceptionsFacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); ``` -------------------------------- ### Add Feeling or Activity to Page Post (PHP SDK) Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Use the PHP SDK to add a feeling or activity to a page post. 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->post( '/page-id/feed', array ( 'message' => 'This is a test activity', 'og_action_type_id' => '383634835006146', 'og_object_id' => '136050896551329', 'og_icon_id' => '609297155780549', ), '{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 Page Feed - HTTP Request Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Use this endpoint to get posts from a Facebook Page. Ensure you have the necessary permissions and access token. ```http GET /v25.0/{page-id}/feed HTTP/1.1 Host: graph.facebook.com ``` -------------------------------- ### GET Unpublished Page Posts Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Retrieve a list of unpublished Page Posts for a given page. You can query the `is_published` field to filter for unpublished posts. ```APIDOC ## GET /page-id/feed ### Description Retrieves posts associated with a Page, including unpublished ones when filtered by `is_published`. ### Method GET ### Endpoint `/{page-id}/feed` ### Query Parameters - **fields** (string) - Required - Specifies the fields to retrieve. Use `is_published` to identify unpublished posts. - **access_token** (string) - Required - Your Page access token. ### Request Example ``` https://graph.facebook.com/{page-id}/feed?fields=is_published&access_token={your-page-access-token} ``` ### Response #### Success Response (200) - **data** (array) - Contains a list of posts. - **is_published** (boolean) - Indicates if the post is published. #### Response Example ```json { "data": [ { "is_published": false, "id": "{post-id}" } ], "paging": { "cursors": { "before": "...", "after": "..." } } } ``` ``` ```curl curl -i -X GET \n "https://graph.facebook.com/{page-id}/feed ?fields=is_published &access_token={your-page-access-token}" ``` ```android GraphRequest request = GraphRequest.newGraphPathRequest( accessToken, "/{page-id}/feed", new GraphRequest.Callback() { @Override public void onCompleted(GraphResponse response) { // Insert your code here } }); Bundle parameters = new Bundle(); parameters.putString("fields", "is_published"); request.setParameters(parameters); request.executeAsync(); ``` ```ios FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/{page-id}/feed" parameters:@{ @"fields": @"is_published",} HTTPMethod:@"GET"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Insert your code here }]; ``` ```javascript FB.api( '/{page-id}/feed', 'GET', {"fields":"is_published"}, function(response) { // Insert your code here } ); ``` ```php try { // Returns a `FacebookFacebookResponse` object $response = $fb->get( '/{page-id}/feed?fields=is_published', '{access-token}' ); } catch(FacebookExceptionsFacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(FacebookExceptionsFacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); ``` -------------------------------- ### Post to Facebook Page Feed using Android SDK Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed This Android SDK example demonstrates posting a message to a Facebook Page's feed using `GraphRequest`. It requires an `AccessToken` and `Bundle` for parameters. ```java Bundle params = new Bundle(); params.putString("message", "This is a test message"); /* make the API call */ new GraphRequest( AccessToken.getCurrentAccessToken(), "/{page-id}/feed", params, HttpMethod.POST, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) { /* handle the result */ } } ).executeAsync(); ``` -------------------------------- ### Facebook Graph API Feed Post Response Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed This is an example of a successful response when posting to a Facebook Page's feed. The response contains the ID of the newly created post. ```json {"id":"post-id"} ``` -------------------------------- ### Get Unpublished Page Posts using cURL Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Use this cURL command to retrieve unpublished Page posts, filtering by the 'is_published' field. Replace '{page-id}' and '{your-page-access-token}' with your specific values. ```curl curl -i -X GET \ "https://graph.facebook.com/{page-id}/feed ?fields=is_published &access_token={your-page-access-token}" ``` -------------------------------- ### Post to Facebook Page Feed using iOS SDK Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed This iOS SDK example shows how to post a message to a Facebook Page's feed using `FBSDKGraphRequest`. It utilizes a completion handler to process the result or errors. ```objective-c NSDictionary *params = @{ @"message": @"This is a test message", }; /* make the API call */ FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/{page-id}/feed" parameters:params HTTPMethod:@"POST"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Handle the result }]; ``` -------------------------------- ### Check Post Promotion Eligibility Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Use this endpoint to retrieve `is_eligible_for_promotion` and `promotable_id` for posts. The `promotable_id` is necessary for creating ads. Ensure you have the correct page access token and necessary permissions. ```cURL curl -i -X GET \ "https://graph.facebook.com/{your-page-id}/feed ?fields=is_eligible_for_promotion,promotable_id &access_token={your-page-access-token}" ``` ```Java GraphRequest request = GraphRequest.newGraphPathRequest( accessToken, "/{your-page-id}/feed", new GraphRequest.Callback() { @Override public void onCompleted(GraphResponse response) { // Insert your code here } }); Bundle parameters = new Bundle(); parameters.putString("fields", "is_eligible_for_promotion,promotable_id"); request.setParameters(parameters); request.executeAsync(); ``` ```Objective-C FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/{your-page-id}/feed" parameters:@{ @"fields": @"is_eligible_for_promotion,promotable_id",} HTTPMethod:@"GET"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Insert your code here }]; ``` ```JavaScript FB.api( '/{your-page-id}/feed', 'GET', {"fields":"is_eligible_for_promotion,promotable_id"}, function(response) { // Insert your code here } ); ``` ```PHP try { // Returns a `FacebookFacebookResponse` object $response = $fb->get( '/{your-page-id}/feed?fields=is_eligible_for_promotion,promotable_id', '{access-token}' ); } catch(FacebookExceptionsFacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(FacebookExceptionsFacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); ``` -------------------------------- ### Publish a Page Post using Android SDK Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Utilize the Android SDK to create and execute a new POST request to publish a page feed item. Ensure you have an access token and the necessary parameters. ```Java GraphRequest request = GraphRequest.newPostRequest( accessToken, "/{your-page-id}/feed", new JSONObject("{\"message\":\"Become a Facebook developer!\",\"link\":\"https://developers.facebook.com\",\"published\":\"1\",\"call_to_action\":\"{\\\"type\\\":\\\"SIGN_UP\\\",\\\"value\\\":{\\\"link\\\":\\\"https://developers.facebook.com\\\"}}\"} "), new GraphRequest.Callback() { @Override public void onCompleted(GraphResponse response) { // Insert your code here } }); request.executeAsync(); ``` -------------------------------- ### Read Page Feed - iOS SDK Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Shows how to retrieve the Page Feed using the iOS SDK. The `startWithCompletionHandler` block processes the result or error. ```objective-c /* make the API call */ FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/{page-id}/feed" parameters:params HTTPMethod:@"GET"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Handle the result }]; ``` -------------------------------- ### Post a Link to a Page (Objective-C) Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed This Objective-C code uses the Facebook SDK to post a link to a Page. It initializes a `FBSDKGraphRequest` with the graph path, parameters including message, link, and published status, and the HTTP method POST. A completion handler is provided for the response. ```objective-c FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/{your-page-id}/feed" parameters:@{ @"message": @"Become a Facebook developer!",@"link": @"https://developers.facebook.com",@"published": @"1",} HTTPMethod:@"POST"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Insert your code here }]; ``` -------------------------------- ### Add Feeling or Activity to Page Post (JavaScript SDK) Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Use the JavaScript SDK to add a feeling or activity to a page post. This requires the Facebook SDK to be initialized. ```javascript /* make the API call */ FB.api( "/page-id/feed", "POST", { "message": "This is a test activity", "og_action_type_id": "383634835006146", "og_object_id": "136050896551329", "og_icon_id": "609297155780549" }, function (response) { if (response && !response.error) { /* handle the result */ } } ); ``` -------------------------------- ### Post a Link to a Page (PHP SDK) Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed This PHP code snippet demonstrates posting a link to a Facebook Page using the Facebook SDK for PHP. It utilizes a try-catch block to handle potential `FacebookFacebookResponseException` or `FacebookExceptionsFacebookSDKException`. The `post` method is used with the graph path, an array of parameters, and the access token. ```php try { // Returns a `FacebookFacebookResponse` object $response = $fb->post( '/{your-page-id}/feed', array ( 'message' => 'Become a Facebook developer!', 'link' => 'https://developers.facebook.com', 'published' => '1' ), '{access-token}' ); } catch(FacebookExceptionsFacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(FacebookExceptionsFacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $graphNode = $response->getGraphNode(); ``` -------------------------------- ### Get Unpublished Page Posts using Objective-C Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Use this Objective-C code to fetch unpublished Page posts with the 'is_published' field. This requires the Facebook SDK for iOS and a valid access token. ```objective-c FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/{page-id}/feed" parameters:@{ @"fields": @"is_published",} HTTPMethod:@"GET"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Insert your code here }]; ``` -------------------------------- ### Sample Response for Link Post Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed This is a sample JSON response received after successfully posting a link to a Facebook Page. It contains the ID of the newly created post. ```json {"id":"{post-id}"} ``` -------------------------------- ### Add Feeling or Activity to Page Post (HTTP) Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Use this method to add a feeling or activity to a page post. Requires `og_action_type_id` and `og_object_id`. `og_icon_id` is optional. ```http POST /v25.0/page-id/feed HTTP/1.1 Host: graph.facebook.com message=This+is+a+test+activity&og_action_type_id=383634835006146&og_object_id=136050896551329&og_icon_id=609297155780549 ``` -------------------------------- ### GET /v25.0/{page-id}/feed Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Retrieves posts from a Facebook Page's feed. This includes posts published by the Page, visitor interactions, and public posts where the Page is tagged. Supports the New Page Experience. ```APIDOC ## GET /v25.0/{page-id}/feed ### Description Retrieves posts from a Facebook Page's feed. This includes posts published by the Page, visitor interactions, and public posts where the Page is tagged. Supports the New Page Experience. ### Method GET ### Endpoint /v25.0/{page-id}/feed ### Requirements To access this endpoint, the requesting user must have one of the following tasks on the Page: - CREATE_CONTENT: Publish content as the Page. - MANAGE: Assign and manage Page tasks. - MODERATE: Respond to comments, delete comments, or manage Instagram content if connected. Additionally, the app must have the following permissions granted: - `pages_read_engagement` - `pages_read_user_content` If you do not own or manage the Page, you will need the Page Public Content Access Feature and should use a system user access token. ### Request Example ```http GET /v25.0/{page-id}/feed HTTP/1.1 Host: graph.facebook.com ``` ### Response #### Success Response (200) - **data** (array) - An array of post objects. - **created_time** (string) - The time the post was created. - **message** (string) - The content of the post. - **id** (string) - The unique ID of the post. - **paging** (object) - Contains cursors and next page information. - **cursors** (object) - For pagination. - **before** (string) - **after** (string) - **next** (string) - URL for the next page of results. #### Response Example ```json { "data": [ { "created_time": "2019-05-17T16:24:04+0000", "message": "Become a Facebook developer!", "id": "{page-id}_2191966997525824" }, { "created_time": "2019-02-26T21:35:42+0000", "message": "Hello world!", "id": "{page-id}_2072371269485398" } ], "paging": { "cursors": { "before": "Q2c4U1pXNT...", "after": "Q2c4U1pXNT..." }, "next": "https://graph.facebook.com/vX.X/{page-id}/feed?access_token={your-page-access-token}&pretty=0&limit=25&after=Q2c4U1pXNT..." } } ``` ``` -------------------------------- ### Sample JSON Response for Page Feed Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed This is a sample JSON response structure for a successful request to the Page Feed endpoint, showing post data and pagination information. ```json { "data": [ { "created_time": "2019-05-17T16:24:04+0000", "message": "Become a Facebook developer!", "id": "{page-id}_2191966997525824" }, { "created_time": "2019-02-26T21:35:42+0000", "message": "Hello world!", "id": "{page-id}_2072371269485398" }, ... { "created_time": "2018-01-26T20:57:22+0000", "message": "Friday Funday!", "id": "{page-id}_1569752556413941" } ], "paging": { "cursors": { "before": "Q2c4U1pXNT...", "after": "Q2c4U1pXNT..." }, "next": "https://graph.facebook.com/vX.X/{page-id}/feed?access_token={your-page-access-token}&pretty=0&limit=25&after=Q2c4U1pXNT..." } } ``` -------------------------------- ### Get Unpublished Page Posts using Android SDK Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed This Android SDK code snippet demonstrates how to request unpublished Page posts, including the 'is_published' field. Ensure you have the Facebook SDK integrated and an access token. ```java GraphRequest request = GraphRequest.newGraphPathRequest( accessToken, "/{page-id}/feed", new GraphRequest.Callback() { @Override public void onCompleted(GraphResponse response) { // Insert your code here } }); Bundle parameters = new Bundle(); parameters.putString("fields", "is_published"); request.setParameters(parameters); request.executeAsync(); ``` -------------------------------- ### Get Unpublished Page Posts using JavaScript SDK Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed This JavaScript SDK snippet illustrates how to request unpublished Page posts, including the 'is_published' field. Make sure the Facebook JavaScript SDK is loaded and initialized. ```javascript FB.api( '/{page-id}/feed', 'GET', {"fields":"is_published"}, function(response) { // Insert your code here } ); ``` -------------------------------- ### Read Page Feed - JavaScript SDK Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Demonstrates how to call the Page Feed endpoint using the JavaScript SDK. The response object should be checked for errors before handling the result. ```javascript /* make the API call */ FB.api( "/{page-id}/feed", function (response) { if (response && !response.error) { /* handle the result */ } } ); ``` -------------------------------- ### POST /page/feed Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Post a link to a Page by sending a POST request to the /page/feed edge. You can set the `published` parameter to `1` to publish immediately or `0` to create an unpublished post. ```APIDOC ## POST /page/feed ### Description Post a link to a Page by sending a POST request to the `/page/feed` edge. Set the `publish` parameter to `1` to publish the post immediately or to `0` to create an unpublished post to be published later. ### Method POST ### Endpoint `/{your-page-id}/feed` ### Parameters #### Query Parameters - **message** (string) - Required - The message content of the post. - **link** (string) - Required - The URL of the link to be shared. - **published** (integer) - Required - `1` to publish immediately, `0` for unpublished post. - **access_token** (string) - Required - A Page access token. #### Request Body *Note: Parameters like `description`, `name`, `picture`, and `thumbnail` can be included in the request body or as query parameters for link customization.* - **description** (string) - Optional - The description of the link (appears beneath the link caption). If not specified, this field is automatically populated by information scraped from the link, typically the title of the page. - **name** (string) - Optional - The name of the link attachment. This field is automatically populated by information scraped from the link. - **picture** (string) - Optional - URL for the image. Image is sourced from the URL supplied in `picture`. - **thumbnail** (file) - Optional - Image file to be uploaded. Accepts `.jpg`, `.jpeg`, `.gif` or `.png`. Image is sourced from the file uploaded in `thumbnail`. This parameter has higher precedence than `picture` and is only available for link posts on Facebook Pages. Not supported in batch requests. ### Request Example ```json { "message": "Become a Facebook developer!", "link": "https://developers.facebook.com", "published": "1" } ``` ### Response #### Success Response (200) - **id** (string) - The ID of the created post. #### Response Example ```json { "id": "{post-id}" } ``` ### Permissions - A Page access token is required. - The link must be owned by the posting Page. Verify ownership using the `ownership_permissions{can_customize_link_posts}` field on the `URL` node before posting. ### Limitations - The `thumbnail` parameter is only available for link posts on Facebook Pages. - The `thumbnail` parameter takes higher precedence over the `picture` parameter. If both are supplied the `picture` parameter is unused. - The `thumbnail` parameter accepts images with extension `.jpg`, `.jpeg`, `.gif` or `.png`. - The `thumbnail` parameter is not supported in batch requests. - For versions 2.10 and lower, `picture`, `name`, `thumbnail`, and `description` are deprecated. `caption` is deprecated for all versions. ``` -------------------------------- ### Link Page Post with Call to Action Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Customize link posts with a call to action, specifying an appropriate action and relevant link. Title, description, caption, and picture are optional and can be derived from Open Graph meta data or scraped from the link. ```APIDOC ## Link Page Post with Call to Action ### Description The `call_to_action` field specifies the appropriate action and relevant link. This link should be the same as the `link` parameter of the Page Post. In this call, `title`, `description`, `caption` and `picture` are optional, and when not provided, Facebook will read the equivalent properties from the link's Open Graph meta data. If the linked web page does not have Open Graph meta data, Facebook will try to guess these properties by scraping the web page's content. ### Parameters *Note: These parameters are typically included within the request body when posting to `/page/feed`.* - **call_to_action** (object) - Optional - An object containing details for the call to action. - **type** (string) - Required if `call_to_action` is used - The type of action (e.g., `LEARN_MORE`, `SHOP_NOW`). - **value** (string) - Required if `call_to_action` is used - The URL associated with the call to action. - **title** (string) - Optional - The title for the link attachment. - **description** (string) - Optional - The description for the link attachment. - **caption** (string) - Optional - The caption for the link attachment. - **picture** (string) - Optional - URL for the image associated with the link attachment. ``` -------------------------------- ### POST /v2.4/page-id/feed Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Add a feeling or activity and an icon to a page post. `og_action_type_id` and `og_object_id` are required. `og_icon_id` is optional. ```APIDOC ## POST /v2.4/page-id/feed ### Description Add a feeling or activity and an icon to a page post. `og_action_type_id` and `og_object_id` are required when posting a feeling or activity. `og_icon_id` is optional however if not used an icon will be automatically supplied based on the `og_object_id`. ### Method POST ### Endpoint /v2.4/{page-id}/feed ### Parameters #### Request Body - **message** (string) - Optional - The text content of the post. - **og_action_type_id** (string) - Required - An action, i.e., _feeling_, _watching_, etc. - **og_object_id** (string) - Required - The target of the action, i.e., _happy_, _movie_, etc. This can be a predefined object or any `page_id`. - **og_icon_id** (string) - Optional - An icon perhaps representing the action type, i.e., a smiley face, a movie icon, etc. ### Request Example ```json { "message": "This is a test activity", "og_action_type_id": "383634835006146", "og_object_id": "136050896551329", "og_icon_id": "609297155780549" } ``` ### Response #### Success Response (200) - **post_id** (string) - The ID of the created post. #### Response Example ```json { "post_id": "10153451049931469_10153451050006469" } ``` ``` -------------------------------- ### POST /feed - Link Post with Custom Uploaded Image Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed This endpoint allows you to publish a post that includes a link and a custom image uploaded from your local file system. ```APIDOC ## POST /feed - Link Post with Custom Uploaded Image ### Description Publishes a post with a link and a custom image uploaded from a local file. ### Method POST ### Endpoint `https://graph.facebook.com/v2.11/{page-id}/feed` ### Parameters #### Query Parameters - **link** (string) - Required - The URL to be shared. - **thumbnail** (file) - Required - The local image file to be used as a thumbnail. - **access_token** (string) - Required - Your Page access token. ### Request Example ``` curl -F 'link=http://www.example.com' \ -F 'thumbnail=@/local/path/to/file/on/hard/drive/image.jpg' \ -F 'access_token=page-access-token'\ https://graph.facebook.com/v2.11/page-id/feed ``` ### Response #### Success Response (200) - **id** (string) - The ID of the newly created post. #### Response Example ```json { "id": "post-id" } ``` ``` -------------------------------- ### Link Post with Local Image Upload using cURL Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed Publish a link post to a page feed using cURL, uploading a local image as a thumbnail. The `-F` flag is used for multipart/form-data encoding. ```cURL curl -F 'link=http://www.example.com' \ -F 'thumbnail=@/local/path/to/file/on/hard/drive/image.jpg' \ -F 'access_token=page-access-token'\ https://graph.facebook.com/v2.11/page-id/feed ``` -------------------------------- ### Post Fields Reference Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed This section lists and describes the various fields that can be retrieved for a Post object. ```APIDOC ## Post Object Fields This document details the fields available for a Post object in the Facebook Graph API v2.4. ### Fields - **`is_popular`** (boolean) - Whether the post is popular. Based on whether the total actions as a percentage of reach exceeds a certain threshold. - **`is_published`** (boolean) - Indicates whether a scheduled post was published (applies to scheduled Page Post only, for users post and instantly published posts this value is always `true`). Note that this value is always `false` for page posts created as part of the Ad Creation process. - **`is_spherical`** (boolean) - Whether the post is a spherical video post. - **`message`** (string) - The status message in the post. - **`message_tags`** (array) - An array of profiles tagged in the `message` text. If you read this field with a User User access token, it returns only the current User. - **`length`** (int) - The length of the tag text, in unicode code points. - **`id`** (string) - ID of the profile that was tagged. - **`name`** (string) - The text used to tag the profile. - **`offset`** (int) - The location in unicode code points of the first character of the tag text in the `message`. - **`type`** (enum{user, page, group}) - The tagged profile's type, `user`, `page`, or `group`. - **`parent_id`** (string) - The ID of a parent post for this post, if it exists. For example, if this story is a 'Your Page was mentioned in a post' story, the `parent_id` is the original post where the mention happened. - **`permalink_url`** (string) - The permanent static URL to the post on www.facebook.com. Example: https://www.facebook.com/FacebookForDevelopers/posts/10153449196353553. - **`place`** (string) - ID of the place associated with this post. - **`privacy`** (object) - The privacy settings of the post. - **`allow`** (string) - If `value` is `CUSTOM`, this is a comma-separated ID list of Users and friend lists (if any) that can see the post. - **`deny`** (string) - If `value` is `CUSTOM`, this is a comma-separated ID list of Users and friend lists (if any) that cannot see the post. - **`description`** (string) - Text that describes the privacy settings, as they would appear on Facebook. - **`friends`** (enum{ALL_FRIENDS, FRIENDS_OF_FRIENDS, SOME_FRIENDS}) - If `value` is `CUSTOM`, this indicates which group of friends can see the post. Values include: `ALL_FRIENDS`, `FRIENDS_OF_FRIENDS`, `SOME_FRIENDS`. - **`value`** (enum{ALL_FRIENDS, CUSTOM, EVERYONE, FRIENDS_OF_FRIENDS, SELF}) - The actual privacy setting. Values include: `ALL_FRIENDS`, `CUSTOM`, `EVERYONE`, `FRIENDS_OF_FRIENDS`, `SELF`. - **`promotable_id`** (string) - ID of post to use for promotion for stories that cannot be promoted directly. - **`properties`** (object) - A list of properties for any attached video, for example, the length of the video. - **`name`** (string) - The property name. - **`text`** (string) - The value of the property. - **`href`** (string) - Any link associated with the property. - **`sheduled_publish_time`** (float) - The UNIX timestamp of the scheduled publish time for the post. Date will be between 10 minutes and 75 days from the time of the `POST` request to publish the post. - **`shares`** (object) - The share count of this post. The share count may include deleted posts and posts you cannot see for privacy reasons. - **`status_type`** (enum{added_photos, added_video, app_created_story, approved_friend, created_event, created_group, created_note, mobile_status_update, published_story, shared_story, tagged_in_photo, wall_post}) - The type of a status update. Values include: `added_photos`, `added_video`, `app_created_story`, `approved_friend`, `created_event`, `created_group`, `created_note`, `mobile_status_update`, `published_story`, `shared_story`, `tagged_in_photo`, `wall_post`. - **`story`** (string) - Text of stories not intentionally generated by Users, such as those generated when a photo has been added. The "Include recent activity stories" migration must be enabled in your app to retrieve this field. - **`story_tags`** (array) - The list of tags in the post description. - **`subscribed`** (boolean) - Whether a User is subscribed to the post. - **`targeting`** (object) - Object that limits the audience for this content. Only audiences in the specified demographics can view this content. The demographics are additive. Each additional value adds its audience to the cumulative targeted audience. These values do not override any Page-level demographic restrictions that may be in place. - **`countries`** (string) - Values of targeting countries as ISO 3166 format codes. - **`locales`** (int) - Targeted locales. Targeting Options of the type `adlocale` may be returned. - **`regions`** (list) - Values for targeted regions. Targeting Options of the type `adregion` may be returned. - **`cities`** (list) - Values for excluded cities. Targeting Options of the type `adcity` may be returned. - **`to`** (object) - Profiles mentioned or targeted in this post. If you read this field with a User access token, it returns only the current User. - **`updated_time`** (float) - The time the post was last updated, which occurs when the post was created, edited, or a User comments on a post, expressed as a UNIX timestamp. ``` -------------------------------- ### POST /feed - Link Post with Image via URL Source: https://developers.facebook.com/docs/graph-api/reference/v24.0/page/feed This endpoint allows you to publish a post that includes a link and an image specified by a URL. ```APIDOC ## POST /feed - Link Post with Image via URL ### Description Publishes a post with a link and an image specified by a URL. ### Method POST ### Endpoint `https://graph.facebook.com/v2.11/{page-id}/feed` ### Parameters #### Query Parameters - **link** (string) - Required - The URL to be shared. - **picture** (string) - Required - The URL of the image to be displayed. - **access_token** (string) - Required - Your Page access token. ### Request Example ``` curl -F 'link=http://www.example.com' \ -F 'picture=https://www.example.com/path/to/image.jpg' \ -F 'access_token=page-access-token'\ https://graph.facebook.com/v2.11/page-id/feed ``` ### Response #### Success Response (200) - **id** (string) - The ID of the newly created post. #### Response Example ```json { "id": "post-id" } ``` ```