kri55h/socialfork

SocialFork PHP:轻松下载 TikTok、YouTube、Facebook、Snapchat 和 Instagram 的视频。无缝集成到您的 PHP 项目中,以访问和管理多个社交平台上的精彩内容。

v1.0.1-beta 2024-01-13 08:50 UTC

This package is auto-updated.

Last update: 2024-09-13 10:30:45 UTC


README

Packagist Version Latest Version Packagist Downloads PHP Version License

概览

SocialFork 是一个 PHP 库,旨在简化从各种社交媒体平台下载视频的过程。

特性

  • 支持从包括 TikTok、SnapChat、Youtube、Facebook、Instagram 和 Twitter 在内的流行社交媒体平台下载视频。
  • 需要依赖 ffmpegyt-dlp

安装

按照以下步骤安装所需的依赖项

安装 ffmpeg

Windows

macOS

brew install ffmpeg

Linux (Debian/Ubuntu)

  • 打开终端并运行以下命令
sudo apt-get update
sudo apt-get install ffmpeg

安装 yt-dlp

  1. 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();
}