revolution/niconico

niconico api

3.1.1 2024-03-15 12:43 UTC

This package is auto-updated.

Last update: 2024-11-15 14:17:41 UTC


README

Build Status Maintainability Test Coverage

Requirements

PHP >= 8.0

実装済みAPI

自分で使う用なので必要なAPIのみ実装。

Install

Composer

composer require revolution/niconico

Usage

example1

<?php
use Revolution\Niconico\Search;
use Revolution\Niconico\Search\Query;

$query = new Query();
$query->q = "初音ミク";
$query->targets = 'title,tags';
$query->_sort = "-viewCounter";
$query->filters(['filters[mylistCounter][gte]=10000', 'filters[commentCounter][gte]=100000']);

$search = new Search();

// returns object
$response = $search->search($query);

// returns array
$response = $search->search($query, true);

example2

<?php
use Revolution\Niconico\Search\Query;

$query = new Query([
  'q'        => '初音ミク',
  'targets'  => 'title,tags',
  '_sort'    => '-viewCounter',
]);

example3

<?php
use Revolution\Niconico\Search\Query;

$query = Query::create([
  'q'        => '初音ミク',
  'targets'  => 'title,tags',
  '_sort'    => '-viewCounter',
])->filters([]);

example4

<?php
use Revolution\Niconico\ThumbInfo;

$thumb = new ThumbInfo();

$thumb->get('sm9');

var_dump($thumb->video_id);//'sm9'

var_dump($thumb->toJson());
var_dump($thumb->toArray());
var_dump($thumb->toSimpleObject());

example5

<?php
use Revolution\Niconico\ThumbInfo;

$thumb = new ThumbInfo('sm9');

エンドポイントが変更されたら

publicプロパティなので変更できる。

$search = new Search();
$search->endpoint = 'http...';

LICENSE

MIT
Copyright kawax