Managing Pages

With the Pages API your app can retrieve and update page information, get page posts and change page settings. To perform these actions, your app needs manage_page permissions from a User who is able to perform Tasks on the Page, and a Page access token.

Page Information

Facebook Pages contain information about a Page, such as a business location, opening hours, email, website, and more.

Your Pages

To manage your Pages information with the API, first read the information and then update it. You will need approval to manage or moderate the Page, have a Page access token and manage_page permissions.

Reading Your Page Information

To read a Page's information, make a GET request with the Page fields you would like to view:

GraphRequest request = GraphRequest.newGraphPathRequest(
  accessToken,
  "/your-page-id",
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});

Bundle parameters = new Bundle();
parameters.putString("fields", "about,attire,bio,location,parking,hours,emails,website");
request.setParameters(parameters);
request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/your-page-id"
           parameters:@{ @"fields": @"about,attire,bio,location,parking,hours,emails,website",}
           HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/your-page-id',
  'GET',
  {"fields":"about,attire,bio,location,parking,hours,emails,website"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->get(
    '/your-page-id?fields=about,attire,bio,location,parking,hours,emails,website',
    'your-page-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();
curl -F 'method=get' \
  	 -F 'fields=about,attire,bio,location,parking,hours,emails,website' \
	 	 -F 'access_token=your-page_access_token' \
	  	https://graph.facebook.com/your-page-id

On success your app receives a JSON containing the Page fields you requested:

{
  "about": "This a Cafe!", 
  "location": {
    "city": "Menlo Park", 
    "country": "United States", 
    "latitude": 37.482266, 
    "longitude": -122.150546, 
    "state": "CA", 
    "street": "1601 Willow Rd", 
    "zip": "94025"
  }, 
  "parking": {
    "lot": 1, 
    "street": 0, 
    "valet": 0
  }, 
  "emails": [
    "hi@hello.com"
  ], 
  "website": "http://www.cafe.com", 
  "id": "{your-page-id}"
}

Updating Your Page Information

To update a Page's information, such as the description, make a POST request with the field and value you want to update. You will need to be approved to create content, manage, or moderate the Page, have a Page access token and have manage_page permissions.

GraphRequest request = GraphRequest.newPostRequest(
  accessToken,
  "/{your-page-id}",
  new JSONObject("{\"description\":\"This is an awesome cafe!\"}"),
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});
request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/{your-page-id}"
           parameters:@{ @"description": @"This is an awesome cafe!",}
           HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{your-page-id}',
  'POST',
  {"description":"This is an awesome cafe!"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->post(
    '/{your-page-id}',
    array (
      'description' => 'This is an awesome cafe!'
    ),
    '{your-page_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();
curl -F 'method=post'
     -F 'description=This is an awesome cafe!'
     -F 'access_token={your-page_access_token}'
  https://graph.facebook.com/{your-page-id}

On success your app receives a JSON response:

{
  "success": true
}

Getting Page Posts

Your app may want to retrieve a Page's posts so that Page admins can monitor and moderate posts.

Endpoint

Permissions

Examples

Send a GET /id/feed request, where id is the id of the Page you are moderating.

GraphRequest request = GraphRequest.newGraphPathRequest(
  accessToken,
  "/{your-page-id}/feed",
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});

request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/{your-page-id}/feed"
           parameters:nil
           HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{your-page-id}/feed',
  'GET',
  {},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->get(
    '/{your-page-id}/feed',
    '{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();
curl -i -X GET \
 "https://graph.facebook.com/{your-page-id}/feed
    ?access_token={your-access-token}"

Sample Response

{
  "data": [
    {
      "created_time": "2019-01-02T18:31:28+0000",
      "message": "This is my test post on my Page.",
      "id": "{your-page-post-id}"
    }
  ],
...

Limitations

  • Live Videos - If a Page post contains a video that has expired, such as a live broadcast, you can get some post fields but not fields related to the video. The video has its own privacy rules. If the video has expired, you must be the page admin to view its information.
  • Message CTA - Any access token can be used to request publicly shared Page posts as long as your app has been approved for the Page Public Content Access Feature. However, posts with message CTAs cannot be accessed using another Page's access token since pages cannot message other pages.

Advanced Topics

The Pages API includes advanced functionality for requesting and changing Page settings.

Retrieve Tasks a User Can Perform on Page

To get a list of tasks a User can perform on a Page, use the following GET request on the Page's roles{tasks} edge. You will need to be approved to moderate the Page, have a Page access token and manage_page permissions.

GraphRequest request = GraphRequest.newGraphPathRequest(
  accessToken,
  "/{your-page-id}",
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});

Bundle parameters = new Bundle();
parameters.putString("fields", "roles{tasks}");
request.setParameters(parameters);
request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/{your-page-id}"
           parameters:@{ @"fields": @"roles{tasks}",}
           HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{your-page-id}',
  'GET',
  {"fields":"roles{tasks}"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->get(
    '/{your-page-id}?fields=roles{tasks}',
    '{your-page-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();
curl -i -X GET \
 "https://graph.facebook.com/{your-page-id}?  
    fields=roles{tasks}
    &access_token={your-page-access-token}"

On success your app receives a JSON containing an array of people who can perform tasks on your Page:

{
  "roles": {
    "data": [
      {
        "name": "JP Jeanne",
        "id": "217128482200107",
        "tasks": [
          "ANALYZE"
        ]
      },
      {
        "name": "Jean-Paul Jeanne",
        "id": "10208271768367309",
        "tasks": [
          "ANALYZE"
        ]
      },
      {
        "name": "Kelly Hoover",
        "id": "10205385197022765",
        "tasks": [
          "ANALYZE",
          "ADVERTISE",
          "MODERATE",
          "CREATE_CONTENT",
          "MANAGE"
        ]
      }
    ],
  }
}

Retrieve Page Ratings and Reviews

Your app can retrieve all ratings and reviews for a Page, including the name of the reviewer, and the review text. Use the following GET request on the Page's ratings edge. You will need to be approved to moderate the Page, have a Page access token and manage_page permissions.

GraphRequest request = GraphRequest.newGraphPathRequest(
  accessToken,
  "/{your-page-id}/ratings",
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});

request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/{your-page-id}/ratings"
           parameters:nil
           HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{your-page-id}/ratings',
  'GET',
  {},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->get(
    '/{your-page-id}/ratings',
    '{your-page-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();
curl -i -X GET \
 "https://graph.facebook.com/{your-page-id}/ratings?access_token={your-page-access-token}"

On success your app receives a JSON containing an array of people who rated and/or reviewed your Page:

{
  "data": [
    {
      "created_time": "2015-03-24T00:51:42+0000", 
      "reviewer": {
        "id": "first-reviewer-user-id", 
        "name": "First Reviewername"
      }, 
      "rating": 4, 
      "review_text": "Hi, I had coffee there once, and it was awesome!"
    }, 
    {
      "created_time": "2014-06-11T01:47:47+0000", 
      "reviewer": {
        "id": "second-reviewer-user-id", 
        "name": "Second Reviewername"
      }, 
      "rating": 5, 
      "review_text": "The coffee is amazing!"
    }
  ], 
  "paging": {
    "cursors": {
      "before": "MTI3MDU4MzExNDo1NDYzNDkxMzUzOTA1NTI=", 
      "after": "MTAwMDAyOTYxMzU2OTc5OjU0NjM0OTEzNTM5MDU1Mg=="
    }
  }
}

Beginning August 17, 2018 we are introducing a new ratings parameter that captures recommendations, recommendation_type with values of positive or negative. This new parameter is replacing the rating parameter with its 1 to 5 scale. Ratings created after August 13 will use this new parameter.

Your app can retrieve all recommendations and reviews for a Page, including the name of the reviewer, and the review text. Use the following GET request on the Page's ratings edge. You will need to be approved to moderate the Page, have a Page access token and manage_page permissions.

GraphRequest request = GraphRequest.newGraphPathRequest(
  accessToken,
  "/{your-page-id}",
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});

Bundle parameters = new Bundle();
parameters.putString("fields", "ratings{open_graph_story,recommendation_type,has_review}");
request.setParameters(parameters);
request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/{your-page-id}"
           parameters:@{ @"fields": @"ratings{open_graph_story,has_rating,has_review}",}
           HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{your-page-id}',
  'GET',
  {"fields":"ratings{open_graph_story,recommendation_type,has_review}"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '/{your-page-id}?fields=ratings{open_graph_story,recommendation_type,has_review}',
    '{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();
curl -i -X GET \
  "https://graph.facebook.com/{your-page-id}?
    fields=ratings{open_graph_story,recommendation_type,has_review}
    &access_token={your-page-access-token}"

For Pages that have both ratings and recommendation types, the following response is returned:

{
  "data": [
    {
      "open_graph_story": {
        "start_time": "2018-07-07T04:35:18+0000",
        "type": "sellers.rates",
        "data": {
          "rating": {
            "value": 5,
            "scale": 5
          },
          "is_hidden": false,
          "seller": {
            "id": "130533530354972",
            "title": "Jasper's Market",
            "type": "seller",
            "url": "https://www.facebook.com/JaspersMarket/"
          }
        },
        "id": "10150030749305470"
      },
      "created_time": "2018-07-07T04:35:18+0000",
      "rating": 5,
      "has_rating": true,
      "has_review": false,
      "recommendation_type": "positive"
    }
  ]
}

For Pages that have only recommendations, the following response is returned:

{
  "data": [
    {
      "open_graph_story": {
        "start_time": "2018-07-07T04:35:18+0000",
        "type": "sellers.rates",
        "data": {
          "is_hidden": false,
          "seller": {
            "id": "130533530354972",
            "title": "Jasper's Market",
            "type": "seller",
            "url": "https://www.facebook.com/JaspersMarket/"
          }
        },
        "id": "10150030749305470"
      },
      "created_time": "2018-07-07T04:35:18+0000",
      "has_rating": false,
      "has_review": false,
      "recommendation_type": "positive"
    }
  ]
}

Block a Person from a Page

There are cases where people may want to block a person from commenting on a Page. Use the blocked edge and the id of the person you want to block, send a POST request:

GraphRequest request = GraphRequest.newPostRequest(
  accessToken,
  "/{your-page-id}/blocked",
  new JSONObject("{\"user\":\"{user-id-to-block}\"}"),
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});
request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/{your-page-id}/blocked"
           parameters:@{ @"user": @"{user-id-to-block}",}
           HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{your-page-id}/blocked',
  'POST',
  {"user":"{user-id-to-block}"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->post(
    '/{your-page-id}/blocked',
    array (
      'user' => '{user-id-to-block}'
    ),
    '{your-page-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();
curl -i -X POST \
 "https://graph.facebook.com/{your-page-id}/blocked
   ?user={user-id-to-block}
   &access_token={your-page-access-token}"

On success your app gets this response:

{
  "{user-id-to-block}": true
}

Update Page Settings

To update a Page's setting make a POST request to {page-id}/settings. In this example, we are allowing our users to message our page:

GraphRequest request = GraphRequest.newPostRequest(
  accessToken,
  "/{your-page-id}/settings",
  new JSONObject("{\"option\":\"{\"USERS_CAN_MESSAGE\": \"true\"}\"}"),
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});
request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/{your-page-id}/settings"
           parameters:@{ @"option": @"{"USERS_CAN_MESSAGE": "true"}",}
           HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{your-page-id}/settings',
  'POST',
  {"option":"{\"USERS_CAN_MESSAGE\": \"true\"}"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->post(
    '/{your-page-id}/settings',
    array (
      'option' => '{"USERS_CAN_MESSAGE": "true"}'
    ),
    '{your-page-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();
curl -i -X POST \
 "https://graph.facebook.com/{your-page-id}/settings?option="{"USERS_CAN_MESSAGE": "true"}&access_token={your-page-access-token}"

On success, your app receives this response:

{
  "success": true
}