lucit/lucit-layout-drive-api

这是一个用于访问Lucit Layout数字广告牌拉取/回显API的PHP包装器composer库

dev-master 2024-01-16 21:55 UTC

This package is auto-updated.

Last update: 2024-09-16 23:17:44 UTC


README

此库已弃用,不再维护。

请迁移到Lucit api的V3版本

资源

旧版信息

以下内容保留以供旧版安装使用

Lucit Layout Drive Api

这是一个包含用于向V1 Lucit Drive api发起请求的小型库的PHP Composer包,用于导出拉取和回显。

Lucit Drive API的完整文档位于: https://lucit.cc/lucit-drive-api/

先决条件

需要PHP和Composer - 需要Lucit Layout API的令牌

安装

composer require lucit/lucit-layout-drive-api

使用此库所需的内容

  • Lucit V1 Api的完整URL - 目前这是: https://layout.lucit.cc/api/v1/
  • V1 Api令牌(Lucit将提供此令牌)
  • 导出ID(Lucit将提供此ID)
  • 位置ID / 数字显示屏ID(这是您的内部ID,我们的活动计划在您的显示屏上运行)

如何获取创意

use \Lucit\LucitDrive;

$LUCIT_DRIVE_URI = "https://layout.lucit.cc/api/v1/":
$LUCIT_DRIVE_TOKEN = "***";

$ld = LucitDrive::Init( $LUCIT_DRIVE_URI,  $LUCIT_DRIVE_TOKEN );

$response = $ld->getItem($EXPORT_ID,$LOCATION_ID);

以下是一个示例响应

请注意以下两个对于发出播放状态所必需的关键数据点

  • lucit_layout_digital_board_id - 映射到您的显示屏的Lucit内部板ID号码
  • creative_id - 此特定图像的编码创意ID号码
Array
(
    [location_id] => SC_MH_2
    [location_name] => 1414 S. Holloway St.
    [lucit_layout_digital_board_id] => 19303
    [item_count] => 6
    [item_total_weight] => 60
    [item_selected_index] => 5
    [items] => Array
        (
            [0] => Array
                (
                    [creative_id] => C1-4C9D-LP-4PcU
                    [creative_datetime] => 2020-07-21T19:15:06+00:00
                    [id] => 51798
                    [object_class] => InventoryPhoto
                    [name] => 16914A 2012 Dodge Durango
                    [slug] => 16914a_2012_dodge_durango
                    [src] => https://theimagehost.home/the/path/1/318/img_5f13398aad2d4_d755bcb77855ce7ef665.png
                    [hash] => "d41d8cd98f00b204e9800998ecf8427e"
                    [hash_algo] => "md5"
                    [width] => 1856
                    [height] => 576
                    [weight] => 10
                    [pingback_url] => https://layout.lucit.cc/api/v1/analytics/track/lucit-drive-play/?creative_id=C1-4C9D-LP-4PcU&lucit_layout_digital_board_id=19303&play_datetime=${PLAY_DATETIME_UTC}&play_duration=${PLAY_DURATION_SECONDS}&api_token=${API_TOKEN}
                    [weight_pct] => 0.16666667
                )

        )

)

如何验证图像响应

您可以通过比较图像的hash与使用hash_algo中指定的算法计算出的图像文件自己的hash来验证图像是否为预期的图像

您可以使用我们的库这样做,如下所示

$ld = LucitDrive::Init( $LUCIT_DRIVE_URI,  $LUCIT_DRIVE_TOKEN );

$response = $ld->getItem($EXPORT_ID,$LOCATION_ID);

$item = $response["items"][0];

$imageIsValid = $ld->validateItemHash( $item );

if( !$imageIsValid )
{
    //Throw an exception
}

如何发送播放统计信息

您可以通过使用库或通过从结果中的pingback-url元素中形成自己的请求来发送播放统计信息(见文档)

use \Lucit\LucitDrive;


$LUCIT_DRIVE_URI = "https://layout.lucit.cc/api/v1/":
$LUCIT_DRIVE_TOKEN = "***";
$DATE_UTC_ISO8601 = "2020-06-28T18:42:26Z"; //UTC TIME
$PLAY_DURATION_SECONDS = 8;

$CREATIVE_ID = GetTheCreativeIdFromLastPullResponse();      //This might be like `C1-4C94-IP-4Cu4`   `creative_id`
$DIGITAL_BOARD_ID = GetTheDigitalBoardIdIdFromLastPullResponse();      //This might be like `12345`  `lucit_layout_digital_board_id`

$ld = LucitDrive::Init( $LUCIT_DRIVE_URI,  $LUCIT_DRIVE_TOKEN );

$response = $ld->play( $CREATIVE_ID, $DIGITAL_BOARD_ID, $DATE_UTC_ISO8601, $PLAY_DURATION_SECONDS);

如果成功,您将收到一个OK响应

Array
(
    [ok] => 1
)

测试此composer库

如果您希望在将其包含在另一个应用程序之前测试此库本身,或者只是使用此库来测试您提供的凭据、导出ID和显示屏ID

  1. 将此存储库克隆到本地目录
  2. 运行 composer install
  3. examples/.env.sample.php复制到examples/.env.php
  4. 使用所需的设置更新.env.php
  5. 运行命令 php examples/example-pull.php,您应该看到有效的输出

许可

所有源代码均在Apache 2.0许可下许可,与Arcanist项目的许可相同。

Lucit

Lucit是Layout背后的公司:该应用程序将大型库存应用程序(汽车、农业、休闲、房地产)实时连接到数字广告牌。

我们实时将库存流式传输到任何地方的数字广告牌。 https://lucit.cc