tapp/php-sdk-bands-in-town-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tapp/php-sdk-bands-in-town-api

Composer 安装命令:

composer require tapp/php-sdk-bands-in-town-api

包简介

PHP SDK for Bands In Town API

README 文档

README

Provides a PHP wrapper for Bands In Town public and search APIs.

Installation

Installing via Composer:

composer require tapp/php-sdk-bands-in-town-api

Usage

Instantiate the API class

use BandsInTownApi\BandsInTownApi;

$bandsInTownApi = new BandsInTownApi;

Public API

Public API documentation:
https://artists.bandsintown.com/support/public-api

$bandsInTownApi->api('public')

Authentication

$bandsInTownApi->withQueryAuth('app_id', 'your-app-id');

Artist Info By Name

$bandsInTownApi->api('public')->artistInfoByName('artist name');

E.g.:

$artistInfoByName = $bandsInTownApi->api('public')->artistInfoByName('Justin Bieber');
$artistInfoByName->body();
// "{"id": "307871", "name": "Justin Bieber", "url": "https://www.bandsintown.com/a/307871?came_from=267&app_id=58c406aaf44bbb601a1bc5a75d0a4ca6", "mbid": "e0140a67-e4d1-4f13-8a01-364355bee46e", "options": {"display_listen_unit": false}, "tracking": [], "image_url": "https://photos.bandsintown.com/large/11112851.jpeg", "thumb_url": "https://photos.bandsintown.com/thumb/11112851.jpeg", "facebook_page_url": "http://www.facebook.com/67253243887", "tracker_count": 5295141, "upcoming_event_count": 0, "support_url": "", "links": [{"type": "itunes", "url": "https://itunes.apple.com/us/artist/justin-bieber/320569549"}, {"type": "youtube", "url": "https://www.youtube.com/user/kidrauhl"}, {"type": "amazon", "url": "https://music.amazon.com/artists/B002F0BWIM"}, {"type": "spotify", "url": "https://open.spotify.com/artist/1uNFoZAHBGtllmzznpCI3s"}, {"type": "snapchat", "url": "https://www.snapchat.com/add/rickthesizzler"}, {"type": "store/merch", "url": "https://shop.justinbiebermusic.com"}, {"type": "tumblr", "url": "https://justinbieber.tumblr.com"}, {"type": "newsletter", "url": "https://www.justinbiebermusic.com"}, {"type": "soundcloud", "url": "https://soundcloud.com/justinbieber"}, {"type": "facebook", "url": "https://www.facebook.com/JustinBieber/"}, {"type": "iheart", "url": "https://www.iheart.com/artist/justin-bieber-44368/"}, {"type": "instagram", "url": "https://www.instagram.com/justinbieber/"}, {"type": "website", "url": "https://www.justinbiebermusic.com/"}, {"type": "vevo", "url": "https://www.youtube.com/user/JustinBieberVEVO"}, {"type": "twitter", "url": "https://twitter.com/justinbieber"}], "artist_optin_show_phone_number": false, "show_multi_ticket": true}"

Artist Info By Id

$bandsInTownApi->api('public')->artistInfoById('artist id');

E.g.:

$artistInfoById = $bandsInTownApi->api('public')->artistInfoById('307871');

Artist Info By Facebook Page Id

$bandsInTownApi->api('public')->artistInfoByFacebookPageId('facebook page id');

E.g.:

$artistInfoById = $bandsInTownApi->api('public')->artistInfoByFacebookPageId('67253243887');

Artist Upcoming Events

$bandsInTownApi->api('public')->artistUpcomingEvents('artist name');

E.g.:

$artistUpcomingEvents = $bandsInTownApi->api('public')->artistUpcomingEvents('Christina Aguilera');;

$artistUpcomingEvents->body();
// [{"id":"104054519","url":"https:\/\/www.bandsintown.com\/e\/104054519?app_id=58c406aaf44bbb601a1bc5a75d0a4ca6&came_from=267&utm_medium=api&utm_source=public_api&utm_campaign=event","datetime":"2023-05-06T15:00:00","title":"Lovers & Friends 2023","description":"","artist":{"id":"39","name":"Christina Aguilera","url":"https:\/\/www.bandsintown.com\/a\/39?came_from=267&app_id=58c406aaf44bbb601a1bc5a75d0a4ca6","mbid":"b202beb7-99bd-47e7-8b72-195c8d72ebdd","options":{"display_listen_unit":false},"tracking":[],"image_url":"https:\/\/photos.bandsintown.com\/large\/12754027.jpeg","thumb_url":"https:\/\/photos.bandsintown.com\/thumb\/12754027.jpeg","facebook_page_url":"http:\/\/www.facebook.com\/5565627823","tracker_count":2024835,"upcoming_event_count":1,"support_url":"","links":[{"type":"facebook","url":"https:\/\/www.facebook.com\/christinaaguilera\/"},{"type":"tiktok","url":"https:\/\/www.tiktok.com\/@xtina"},{"type":"linktree","url":"https:\/\/linktr.ee\/xtinauniverse"},{"type":"website","url":"https:\/\/www.christinaaguilera.com\/"},{"type":"youtube","url":"https:\/\/www.youtube.com\/christinaaguilera"},{"type":"twitter","url":"https:\/\/twitter.com\/XTINA"},{"type":"instagram","url":"https:\/\/www.instagram.com\/xtina\/"},{"type":"spotify","url":"https:\/\/open.spotify.com\/artist\/1l7ZsJRRS8wlW3WfJfPfNS"},{"type":"itunes","url":"https:\/\/music.apple.com\/artist\/christina-aguilera\/259398"},{"type":"soundcloud","url":"https:\/\/soundcloud.com\/christinaaguilera"}],"artist_optin_show_phone_number":false,"show_multi_ticket":true},"venue":{"location":"Las Vegas, NV","name":"Lovers & Friends 2023","latitude":"36.1431237","longitude":"-115.1621698","street_address":"311 W Sahara Ave","postal_code":"89101","city":"Las Vegas","country":"United States","region":"NV"},"lineup":["Christina Aguilera"],"offers":[{"type":"Tickets","url":"https:\/\/www.bandsintown.com\/t\/104054519?app_id=58c406aaf44bbb601a1bc5a75d0a4ca6&came_from=267&utm_medium=api&utm_source=public_api&utm_campaign=ticket","status":"available"}],"artist_id":"39","on_sale_datetime":"","festival_start_date":"2023-05-06","festival_end_date":"2023-05-06","festival_datetime_display_rule":"date","starts_at":"2023-05-06T15:00:00","ends_at":"2023-05-06T23:30:00","datetime_display_rule":"datetime","bandsintown_plus":false}]
$artistUpcomingEvents->status(); 
// 200

Artist Events By Date Range

$bandsInTownApi->api('public')->artistEventsByDateRange('artist name');

E.g.:

$artistEventsByDateRange = $bandsInTownApi->api('public')->artistEventsByDateRange('Christina Aguilera', '2023-05-01,2023-06-01');

Artist Past Events

$bandsInTownApi->api('public')->artistPastEvents('artist name');

E.g.:

$artistPastEvents = $bandsInTownApi->api('public')->artistPastEvents('Christina Aguilera');

All Artist Events

$bandsInTownApi->api('public')->artistAllEvents('artist name');

E.g.:

$allArtistEvents = $bandsInTownApi->api('public')->artistAllEvents('Christina Aguilera');

Search API

Search API documentation: https://artists.bandsintown.com/support/partner-search-api/

$bandsInTownApi->api('search')

Authentication

$bandsInTownApi->withHeaderAuth('your-api-key');

Available methods

Array of entities to search

->entities([
    [
        'type' => 'artist',
        'order' => 'trackers',
        'limit' => 2,
        'offset' => 0,
    ],
])

Term to search

->term('Bell')

Type to search. Possible values: 'streaming', 'physical', 'both' (default)

->type('streaming')

Genre to search. Possible values: see https://artists.bandsintown.com/support/partner-search-api/#query_string_parameters

->genre('pop')

Genres to search. Possible values: see https://artists.bandsintown.com/support/partner-search-api/#query_string_parameters

->genres([
    'pop', 
    'jazz'
])

Restrict search to the provided scopes of entity for a given term. Possible values: 'artist', 'event', 'venue', 'event_id'

->scopes([
    'artist',
])

Limit search to a provided region. Not applicable for artist

->region([
    'latitude' => 45.496112,
    'longitude' => -73.569315,
])

Limit search to a range of dates. Only for event search

->period([
    'starts_at' => '2021-08-20T00:00:00Z',
    'ends_at' => '2021-08-23T00:00:00Z',
])

Filter search. Possible values: 'on tour' (for artist search), "recommended", "tracked artist" (when user object is provided)

->filter('on tour')

Send the request

->send()

Examples:

Single entity with pagination (search by artist with pagination)

$artist = $bandsInTownApi->api('search')
    ->entities([
        [
            'type' => 'artist',
            'order' => 'trackers',
            'limit' => 2,
            'offset' => 0,
        ],
    ])
    ->term('Lady')
    ->scopes([
        'artist'
    ])
    ->send();

Retrieve multiple entities (search by artist and events with pagination)

$artistAndEvent = $bandsInTownApi->api('search')
    ->entities([
        [
            'type' => 'artist',
            'order' => 'trackers',
            'limit' => 2,
            'offset' => 0,
        ],
        [
            'type' => 'event',
            'order' => 'rsvps',
            'limit' => 4,
        ]
    ])
    ->term('Lady')
    ->scopes([
        'artist',
        'event',
    ])
    ->send();

Retrieve a specific event

$event = $bandsInTownApi->api('search')
    ->entities([
        [
            'type' => 'event',
        ]
    ])
    ->term('102617588')
    ->scopes([
        'event_id',
    ])
    ->send();

Search events by artist id

$event = $bandsInTownApi->api('search')
    ->entities([
        [
            'type' => 'event',
            'order' => 'rsvps',
            'limit' => 4,
        ],
    ])
    ->term('22741')
    ->scopes([
        'artist_id',
    ])
    ->send();

Search venues by name or by id

// search by venue name
$venue = $bandsInTownApi->api('search')
    ->entities([
        [
            'type' => 'venue',
        ],
    ])
    ->term('Bell Centre')
    ->scopes([
        'venue',
    ])
    ->send();
// search by venue id
$venue = $bandsInTownApi->api('search')
    ->entities([
        [
            'type' => 'venue',
        ],
    ])
    ->term('10003087')
    ->scopes([
        'venue_id',
    ])
    ->send();

Search events by venue id

$events = $bandsInTownApi->api('search')
    ->entities([
        [
            'type' => 'event',
        ],
    ])
    ->term('10003087')
    ->scopes([
        'venue_id'
    ])
    ->send();

Search events and artists who played in a specific venue by venue id and genre

$events = $bandsInTownApi->api('search')
    ->entities([
        [
            'type' => 'event',
        ],
    ])
    ->term('10003087')
    ->genre('pop')
    ->send();

Search events by GPS coordinates and genre

$events = $bandsInTownApi->api('search')
    ->entities([
        [
            'type' => 'event',
        ],
    ])
    ->region([
        'latitude' => 45.496112,
        'longitude' => -73.569315,
    ])
    ->genre('pop')
    ->send();

Search live streaming events

$events = $bandsInTownApi->api('search')
    ->entities([
        [
            'type' => 'event',
        ],
    ])
    ->term('jason wild')
    ->type('streaming')
    ->send();

Search live streaming events by genre

$events = $bandsInTownApi->api('search')
    ->entities([
        [
            'type' => 'event',
        ],
    ])
    ->genre('latin')
    ->type('streaming')
    ->send();

Search physical events, last modified in a period of time, ordered by start date

$events = $bandsInTownApi->api('search')
    ->entities([
        [
            'type' => 'event',
            'order' => 'start_date',
            'limit' => 199,
            'offset' => 0,
        ],
    ])
    ->term('2021-08-20T00:00:00ZTO2021-08-23T00:00:00Z')
    ->scopes(['last_modified_date'])
    ->type('physical')
    ->send();

Testing

./vendor/bin/pest

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Contributions are welcome! :)

License

The MIT License (MIT). Read License for more information.

tapp/php-sdk-bands-in-town-api 适用场景与选型建议

tapp/php-sdk-bands-in-town-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.33k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 05 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「sdk」 「tapp network」 「bands in town」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 tapp/php-sdk-bands-in-town-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tapp/php-sdk-bands-in-town-api 我们能提供哪些服务?
定制开发 / 二次开发

基于 tapp/php-sdk-bands-in-town-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4.33k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-17