kri55h / socialfork
SocialFork PHP:轻松下载 TikTok、YouTube、Facebook、Snapchat 和 Instagram 的视频。无缝集成到您的 PHP 项目中,以访问和管理多个社交平台上的精彩内容。
v1.0.1-beta
2024-01-13 08:50 UTC
Requires
- php: >=7.4
- ext-json: *
This package is auto-updated.
Last update: 2024-09-13 10:30:45 UTC
README
概览
SocialFork 是一个 PHP 库,旨在简化从各种社交媒体平台下载视频的过程。
特性
安装
按照以下步骤安装所需的依赖项
安装 ffmpeg
Windows
- 访问官方 ffmpeg 下载页面。
- 按照说明下载并安装可执行文件。
macOS
- 如果尚未安装,请按照Homebrew 网站上的说明安装 Homebrew。
- 打开终端并运行以下命令
brew install ffmpeg
Linux (Debian/Ubuntu)
- 打开终端并运行以下命令
sudo apt-get update sudo apt-get install ffmpeg
安装 yt-dlp
- Windows、macOS、Linux
- 打开终端并运行以下命令
pip install -U yt-dlp
如果您尚未安装 pip
,可以按照此处的说明获取它。
使用方法
现在您已安装了先决条件,可以开始使用 Social Fork。
1. 通过 Composer 安装 Social Fork
在项目根目录中运行以下命令
composer require kri55h/socialfork
2. 在代码中使用 Social Fork
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(); }