Social API Modules

These modules support Facebook/Instagram account setup, token maintenance, and diagnostics for the Instagram publishing pipeline.

Debug Access Token

app.facebook.debug_facebook_access_token.debug_facebook_access_token(params: dict) dict

Get info about the access token set in .env as FB_ACCESS_TOKEN. API Endpoint: https://graph.facebook.com/debug_token?input_token={input-token}&access_token={valid-access-token}

Args:

params (dict): params from .env

Returns:

dict: response from the endpoint. Contains the data_access_expires_at and expires_at

Get Instagram Account

app.facebook.get_instagram_account.get_instagram_account(params: dict) dict

Get instagram_account_id. page_id should be known and present in the params. API Endpoint: https://graph.facebook.com/{graph-api-version}/{page-id}?access_token={your-access-token}&fields=instagram_business_account

Args:

params (dict): params from .env file. Required keys are page_id, access_token, endpoint_base

Returns:

dict: data from the endpoint. It contains instagram_business_account id

Get User Pages

app.facebook.get_user_pages.get_user_pages(params: dict) dict

Get facebook pages for a user. access_token is required in the params. API Endpoint: https://graph.facebook.com/{graph-api-version}/me/accounts?access_token={access-token}

Args:

params (dict): params from .env file. Required keys are access_token, endpoint_base

Returns:

object: data from the endpoint. It contains the page id, name, and category

Long-Lived Access Token

app.facebook.long_lived_access_token_facebook.get_long_lived_access_token(params: dict) dict

Get long lived access token from a short lived access token. client_id, client_secret, and access_token are required in the params. API Endpoint: https://graph.facebook.com/{graph-api-version}/oauth/access_token?grant_type=fb_exchange_token&client_id={app-id}&client_secret={app-secret}&fb_exchange_token={your-access-token}

Args:

params (dict): params from .env file. Required keys are client_id, client_secret, access_token, endpoint_base

Returns:

dict: response from the endpoint. Contains the long lived access token.