Skip to main content

A python package for managing Meta GraphQL API.

Project description

python-sage-meta

Black Pylint codecov

PyPI release Supported Python versions Documentation License GitHub last commit

Table of Contents

Introduction

python-sage-meta is a comprehensive Python package designed to simplify the management of Facebook and Instagram operations through the Facebook Graph API. It provides easy-to-use interfaces for managing accounts, media, comments, hashtags, content publishing, and product tagging. This package is ideal for developers looking to integrate social media functionalities into their applications seamlessly.

Features

  • Account management for Facebook and Instagram accounts
  • Media management for uploading and handling Instagram photos, videos, and carousels
  • Comment management for Instagram comments, mentions, and replies
  • Hashtag management for searching and retrieving hashtag information
  • Content publishing for Instagram photos, videos, and carousels
  • Product tagging for Instagram media

Installation

To install python-sage-meta, use pip:

pip install python-sage-meta

Configuration

The sage_meta package requires certain configuration variables to establish and manage interactions with the Facebook Graph API effectively.

This library offers flexibility to accommodate both single-user and multi-user scenarios:

  • Single User Configuration: If you are integrating this library into a Django application or any other single-user setup, you can define the necessary variables within your application's settings. This approach ensures that the configuration behaves as a single user, maintaining a consistent and straightforward setup.

  • Multi-User Configuration: For applications requiring support for multiple users, such as a web application with various user accounts, the library allows you to dynamically change the configuration variables upon each instantiation. This flexibility ensures that each user can have their own Facebook Graph API settings, enabling personalized social media management.

Configuration Variables

To configure the sage_meta package, you need to set the following variables:

Access Token: The Facebook Graph API access token used for authentication.

Example Configuration

Here is an example of how to set up these variables in your project:

  ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"

Single User Configuration

For a single-user setup, you can configure the sage_meta package as follows:

    import sage_meta

    ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"

    fb_client = sage_meta.FacebookClient(
        access_token=ACCESS_TOKEN
    )

Multi-User Configuration

For multi-user applications, you can dynamically configure the sage_meta package upon each instantiation:

    import sage_meta

    class UserService:
        def __init__(self, user_access_token):
            self.fb_client = sage_meta.FacebookClient(
                access_token=user_access_token
            )

        def get_user_data(self):
            return self.fb_client.get_user_data()

    # Example usage
    user_service = UserService("USER_SPECIFIC_ACCESS_TOKEN")
    user_data = user_service.get_user_data()

This example demonstrates how to dynamically configure the package for different users, ensuring personalized management of Facebook and Instagram operations for each user.

Ensure that your configuration is securely managed, especially the access tokens, to prevent unauthorized access to your Facebook and Instagram accounts.

Examples

Example 1: Account Management

This example demonstrates how to manage Facebook and Instagram accounts using the AccountHandler class.

from sage_meta.services.base import FacebookClient

ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"
fb_client = FacebookClient(access_token=ACCESS_TOKEN)
accounts = fb_client.account_handler.get_accounts()
for account in accounts:
    print(account.name)

Example 2: Media Management

This example demonstrates how to manage media for Instagram using the MediaHandler class.

from sage_meta.services.base import FacebookClient

ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"
fb_client = FacebookClient(access_token=ACCESS_TOKEN)
media_items = fb_client.media_handler.get_instagram_media(insta_id="INSTAGRAM_BUSINESS_ACCOUNT_ID")
for media in media_items:
    print(media.caption)

Example 3: Content Publishing

This example demonstrates how to publish content to Instagram using the ContentPublishing class.

from sage_meta.services.base import FacebookClient

ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"
fb_client = FacebookClient(access_token=ACCESS_TOKEN)
publish_response = fb_client.content_publisher.publish_photo(
    image_url="https://example.com/image.jpg",
    caption="This is an example caption."
)
print(publish_response)

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_sage_meta-0.1.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_sage_meta-0.1.0-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file python_sage_meta-0.1.0.tar.gz.

File metadata

  • Download URL: python_sage_meta-0.1.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11

File hashes

Hashes for python_sage_meta-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1889c50ba7846ce16930595815ee4600679edb93b919836b081a1340bb64dac4
MD5 4c53554bb0311dea5a214a8993414237
BLAKE2b-256 57170212f08a9c5100c4bfeb16528fa421caa976f4cb0abde63b7be55250db1f

See more details on using hashes here.

File details

Details for the file python_sage_meta-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: python_sage_meta-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11

File hashes

Hashes for python_sage_meta-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1363551c9c94a3205bd192d8abe0a31e81427b910711f942095cb0374a1c8a13
MD5 b3cb03bb74314dcd3d90e3615b70a34e
BLAKE2b-256 a56eb4e752d6765aaa20753c3fb39e067d7ea89f4d2c36429bbd48afafeb3eb2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page