Download the PHP package hamzahassanm/laravel-social-auto-post without Composer
On this page you can find all versions of the php package hamzahassanm/laravel-social-auto-post. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hamzahassanm/laravel-social-auto-post
More information about hamzahassanm/laravel-social-auto-post
Files in hamzahassanm/laravel-social-auto-post
Package laravel-social-auto-post
Short Description Laravel social media auto post package
License MIT
Informations about the package laravel-social-auto-post
Laravel Social Auto Post
A Laravel package to facilitate automatic social media posting on platforms like Facebook and Telegram.
Available Languages
- English (EN)
- العربية (AR)
Installation
To install the package, run the following command:
Configuration
After installing the package, publish the configuration file using the following command:
This command will create a config/autopost.php
file where you can configure your social media credentials and other settings.
Example Configuration
In your config/autopost.php
file, add your Facebook and Telegram credentials:
Ensure you update your .env
file with the necessary credentials:
Usage
The package provides two facades for simple interaction with Facebook and Telegram.
Facebook Methods
The FaceBook
facade provides the following methods:
1. share(string $caption, string $url)
Posts a status update with a URL to your Facebook page.
2. shareImage(string $caption, string $image_url)
Posts an image with a caption to your Facebook page.
3. shareVideo(string $caption, string $video_url)
Posts a video with a caption to your Facebook page.
4. getPageInsights(array $metrics = [], array $additionalParams = [])
Retrieves insights (metrics) about your Facebook page. You can specify an array of metrics to retrieve or leave it empty to get default metrics.
This method returns various insights depending on the metrics requested. The metrics can include page impressions, page views, page engagement, and more.
5. getPageInfo()
Retrieves basic information about your Facebook page, such as name, category, and other details.
This method is useful when you want to fetch the current details of your Facebook page, such as the number of likes, category, or description.
Telegram Methods
The Telegram
facade offers the following methods for interacting with Telegram:
1. share(string $caption, string $url)
Posts a message with a caption and link to your Telegram chat.
2. shareImage(string $caption, string $image_url)
Posts an image with a caption to your Telegram chat.
3. shareDocument(string $caption, string $document_url)
Shares a document with a caption in your Telegram chat.
4. shareVideo(string $caption, string $video_url)
Posts a video with a caption to your Telegram chat.
5. getUpdates()
Retrieves updates (messages and events) from your Telegram bot.
Error Handling
When using the package to post on social media, exceptions might occur if the API tokens are invalid, the API limits are exceeded, or there's an error with the request. You can handle such exceptions as follows:
Facades
The package provides two facades for easy access to social media platforms:
FaceBook
- For posting to Facebook via the Facebook Graph API.Telegram
- For posting to Telegram via the Telegram Bot API.
Facebook Facade Methods
- share($caption, $url): Posts a status update with a URL.
- shareImage($caption, $image_url): Posts an image with a caption.
- shareVideo($caption, $video_url): Posts a video with a caption.
- getPageInsights($metrics = [], $additionalParams = []): Retrieves Facebook Page insights.
- getPageInfo(): Retrieves Facebook Page information.
Telegram Facade Methods
- share($caption, $url): Posts a message with a URL.
- shareImage($caption, $image_url): Posts an image with a caption.
- shareVideo($caption, $video_url): Posts a video with a caption.
- getUpdates(): Retrieves updates, such as messages or events, from the Telegram bot.
Service Provider (Optional for Laravel 11)
For Laravel 11, you need to manually register the service provider in the bootstrap/providers.php
file if auto-discovery isn't enabled:
For Laravel versions that support package auto-discovery, this step is unnecessary.
Testing the Package
Using Docker for Testing
To ensure that the package works correctly in all environments, you can use Docker to build a consistent testing environment.
1. Clone the Repository
2. Build the Docker Image
Use Docker to build the testing environment:
3. Run the Tests
After building the Docker image, you can run the tests:
This command will start a container and execute the tests using PHPUnit.
4. Manually Access the Docker Container (Optional)
For debugging purposes, you can manually enter the container:
Within the container, you can run additional tests or commands:
5. Clean Up Docker Containers
Once testing is complete, remove the containers:
License
This package is licensed under the MIT License.
Contributing
Feel free to open issues or submit pull requests to improve this package. Please ensure that your contributions adhere to the existing code style and pass all tests.
Contact
For any questions or issues, feel free to reach out to HamzaHassanM.
Additional Notes
1.Future Enhancements: The package could be expanded to support additional platforms such as Twitter, LinkedIn, or Instagram.