Get Facebook Page Reviews Using API

Minahil Faisal
import logging
from fastapi import FastAPI, Depends
from pydantic import BaseModel
import os
from some_get_request_handler import handle_get_endpoint
from some_post_request_handler import handle_post_endpoint, Data
from facebook_reviews import get_facebook_page_reviews

logger = logging.getLogger(__name__)

app = FastAPI()

class FacebookPageReviewRequest(BaseModel):
    page_id: str"/facebook_reviews")
def facebook_reviews(request: FacebookPageReviewRequest):
    access_token = os.environ['FACEBOOK_ACCESS_TOKEN']
        reviews = get_facebook_page_reviews(request.page_id, access_token)
        return {"reviews": reviews}
    except Exception as e:

About this template

An app for fetching a logged-in pages's review using the Facebook API. This app uses the FastAPI to create an endpoint to call the Facebook API for getting the page reviews. A facebook access token for the page will be needed to make the API call. The permission scope you will need for the access token is `pages_read_user_content`.

Introduction to the Get Facebook Page Reviews Using API Template

Welcome to the "Get Facebook Page Reviews Using API" template! This template is designed to help you fetch reviews from a Facebook page using the Facebook Graph API. It leverages FastAPI to create an endpoint that interacts with the Facebook API, allowing you to retrieve page reviews easily. Before you can use this template, you'll need a Facebook access token with the `pages_read_user_content` permission scope.

Clicking Start with this Template

To begin using this template, simply click on the "Start with this Template" button. This will pre-populate the code in the Lazy Builder interface, so you won't need to copy, paste, or delete any code manually.

Initial Setup: Adding Environment Secrets

Before you can test the app, you'll need to set up an environment secret for the Facebook access token. Here's how to do it:

  • Go to the Environment Secrets tab within the Lazy Builder.
  • Create a new secret with the key `FACEBOOK_ACCESS_TOKEN`.
  • For the value, you'll need to obtain an access token from Facebook. You can do this by creating a Facebook app and going through the process to generate an access token with the required permissions. Detailed instructions can be found in the Facebook Access Tokens documentation.

Test: Pressing the Test Button

Once you have set up your environment secret, press the "Test" button. This will begin the deployment of the app and launch the Lazy CLI.

Entering Input: Filling in User Input

After pressing the "Test" button, if the app requires any user input, the Lazy App's CLI interface will prompt you to provide it. For this template, you will be asked to enter the Facebook page ID for which you want to fetch reviews.

Using the App

After deployment, Lazy will provide you with a dedicated server link to use the API. Additionally, since this template uses FastAPI, you will also be provided with a link to the FastAPI documentation at `/docs` where you can test the API endpoints directly.

Integrating the App

If you wish to integrate this app into another service or frontend, you can use the server link provided by Lazy. For example, you can make POST requests to the `/facebook_reviews` endpoint with the page ID to fetch reviews. Here's a sample request you might use:

POST /facebook_reviews HTTP/1.1
Host: [Your Lazy Server Link]
Content-Type: application/json

  "page_id": "your_facebook_page_id_here"

And here's a sample response you might receive:

  "reviews": {
    "data": [
        "created_time": "2021-01-01T00:00:00+0000",
        "recommendation_type": "positive",
        "review_text": "Great service and support!"
      // ... more reviews ...

Remember, you can use the `/docs` endpoint to interact with the API and see the full specifications of the requests and responses.

That's it! You're now ready to fetch Facebook page reviews using the Lazy platform. Happy building!

Last published
June 15, 2024

More templates like this

PDF Data Extraction and Excel Transfer

An app for extracting name, phone number, and email data from PDF files and transferring it to Excel.


GPT-4 Exam Generator

This app uses GPT-4 to generate a PDF of a new exam based on an uploaded PDF of a past exam.


Job Search Website

A customisable one-page job search website with a search bar and a search button that displays UI cards of matching jobs. You need to have a (free) account on to get the API key required for this to work.

React JS
Get Facebook Page Reviews Using API