shatodj/bolt-soundcloud-slug-resolver

Bolt CMS Soundcloud Slug Resolver 扩展。

1.0.0 2020-05-03 17:57 UTC

This package is auto-updated.

Last update: 2024-09-10 01:52:23 UTC


README

该扩展提供了Twig模板运行时函数,可以解析Soundcloud Slug并将数据注入到TWIG模板中。

{% set sc_resolved = soundcloud_resolve('shatopaulrockseek/sets/singles') %}
Soundcloud Title {{ sc_resolved.data.title }}

免责声明

在您开始使用此扩展在您的项目之前,请注意您必须首先注册您的Soundcloud应用以获取客户端凭证。然而,由于请求量很大,Soundcloud已经停止提供新的应用注册,没有人知道他们将以何种创新方式重新开始。

您仍然可以在Google上搜索一些现有的凭证或尝试从Soundcloud网站和浏览器控制台(F12)流量视图中提取CLIENT_ID

安装

  1. 从Bolt市场

    • 在Bolt扩展部分找到shatodj/bolt-soundcloud-slug-resolver
  2. 使用composer

    • 转到Bolt项目/extensions文件夹并运行
    composer require shatodj/bolt-soundcloud-slug-resolver
  3. 暴力安装(如果市场不起作用) :)

    • 将新的bolt-soundcloud-slug-resolver仓库条目添加到/extensions/composer.json,例如:
     "repositories": {
        "packagist": false,
        "bolt": {
            "type": "composer",
            "url": "https://market.bolt.cm/satis/"
        },
        "bolt-soundcloud-slug-resolver": {
            "type": "git",
            "url": "https://github.com/shatodj/bolt-soundcloud-slug-resolver"
        }
    },
    
    • minimum-stabilityextensions/package.json中更改为dev
    "minimum-stability": "dev",
    • extensions/package.json中添加新的require条目,例如:
    require: {
        // ..
        "shatodj/bolt-soundcloud-slug-resolver": "dev-master@dev"
    }
    

使用

使用新的twig函数soundcloud_resolve('/your_dj_slug/your_track')从Soundcloud获取数据。

<div>
    {% set sc_resolved = soundcloud_resolve('shatopaulrockseek/sets/singles') %}
    {% if sc_resolved.error is not null %}
        {{ sc_resolved.error.message }}
    {% else %}
        Soundcloud Title {{ sc_resolved.data.title }}
    {% endif %}
</div>

该函数返回此数据对象

{
    // error object with info about errors (eg. 401, not autorized) \Throwable interface
    error: {
        message: "string"
        code: "string"
    },
    // an actual Soundcloud data, or null (if `error` prop. is not null)
    data: {} 
}

您可以自由地尝试其他标准Soundcloud slug。更多详细信息请查看Soundcloud HTTP API和/resolve资源。

配置

确保为扩展设置正确的设置。

# Soundcloud BASE URL. Change this when the default URL is not working with the desired `CLIENT_ID`.
# eg.: https://api-mobi.soundcloud.com
base_url: https://api.soundcloud.com

# In case you do not own your developer Client ID, try to extract one
# from browser console (F12) when refreshing Soundcloud page or playback track.
client_id: <CLIENT_ID>

许可证

MIT