freezbi/freezbi-php-sdk

Freezbi 通知系统的 PHP SDK

dev-master 2022-03-03 16:48 UTC

This package is not auto-updated.

Last update: 2024-09-24 03:49:18 UTC


README

Freezbi SDK 是一个用于与 Freezbi 通知系统 交互的 PHP 客户端库。

安装

SDK 使用 PHP 5.4 编写,不依赖于外部包。您只需确保 curl 和 openssl 扩展(PHP 标准发行版的一部分)已启用在您的 PHP 安装中。

项目旨在遵守 PSR-4 规范,以便从文件路径自动加载类。命名空间前缀为 'Freezbi',基本目录为 '{your-installation-dir}/'。

但如果不是使用 PSR-4,安装过程与下载包并将其存储在任何可包含的位置一样简单。

require_once '{your-installation-dir}/Freezbi/Autoloader.php';

使用 Composer 安装

您可以使用 Composer 将 Freezbi SDK 库作为项目依赖项。在存储库中有一个 composer.json 文件,并在 Packagist 上进行了引用。

使用 Composer 安装简单、可靠:步骤 1 - 将 Freezbi SDK 添加到您的 composer.json 文件中,如下所示

"require": {
    ...
    "freezbi/freezbi-php-sdk": "dev-master"
},

步骤 2 - 使用 Composer 更新您的依赖项

you@yourhost:/path/to/project$ php composer.phar update freezbi/freezbi-php-sdk

库已添加到您的依赖项中,准备使用。

许可证

Freezbi SDK 根据 MIT 许可证分发,请参阅 LICENSE 文件。

联系方式

使用 Freezbi 联系页面 报告错误或建议功能。

示例

示例目录中有 3 个示例

  • 1 个示例,不进行任何 HTTP 请求
  • 1 个示例,在 freezbi 网站上进行 HTTP 请求(获取最后一条帖子)
  • 1 个示例,进行带有参数的 HTTP 请求(每个参数 1 次调用)=> YouTube 频道订阅

示例用法

    // Init the Freezbi Api
    $freezbiApi = new Freezbi\FreezbiApi();
    $freezbiApi->TemporaryFolder = 'temp/';
    $freezbiApi->Delay = 3600 * 24; // Each remote check will be separated by 24 hours
    
    // Create a new Notification with its name, url, and body type
    $notification = new \Freezbi\Notification\SingleStreamNotification('freezbiblog');
    
    // Prepare the api for that SingleStreamNotification
    $freezbiApi->prepare($notification);
    
    $notification->Action = function() use ($freezbiApi) {
    
        // Prepare a response
        $response = new Response();
    
        $datetime = new \DateTime();
    
        if ($datetime->format('m-d') == '06-23') {
            $response->SendNotification = true;
            $response->Title = 'Birthday';
            $response->Message = 'This is Alan Turing\'s birthday';
            $response->Data = 'https://fr.wikipedia.org/wiki/Alan_Turing';
        }
    
        return $response;
    };
    
    // Your script must return the output of the execute method
    echo $freezbiApi->execute();