SocialFork is a PHP library designed to simplify the process of downloading videos from various social media platforms.
- Supports downloading videos from popular social media platforms, including TikTok, SnapChat, Youtube, Facebook, Instagram, and Twitter.
- Requires ffmpeg and yt-dlp as dependencies.
Follow the steps below to install the required dependencies:
- Visit the official ffmpeg download page.
- Follow the instructions to download and install the executable.
- Install Homebrew if you haven't already by following the instructions on Homebrew's website.
- Open a terminal and run the following command:
brew install ffmpeg
- Open a terminal and run the following command:
sudo apt-get update
sudo apt-get install ffmpeg
- Windows, macOS, Linux:
- Open a terminal and run the following command:
pip install -U yt-dlp
If you don't have pip
installed, you can get it by following the instructions here.
Now that you have the prerequisites installed, you can proceed to use Social Fork.
Run the following command in your project's root directory:
composer require kri55h/socialfork
use Kri55h\SocialFork;
try {
// Instantiate SocialFork
$socialFork = new SocialFork();
// Set the URL of the post you want to download
$socialFork->setUrl('<social_media_post_url>');
// Set the path where you want to store the downloaded video
$socialFork->setDownloadPath('<path_to_store_video>');
// Set the desired name (without extension) for the downloaded video
$socialFork->setName('<name_without_extension>');
// Trigger the download process
$videoSaved = $socialFork->download();
if ($videoSaved) {
return 'Video saved!';
} else {
return 'Failed to save video.';
}
} catch (Exception $e) {
// Handle any exceptions or errors that occurred during the process
return 'An error occurred: ' . $e->getMessage();
}