niconico api


Keywords
niconico
License
MIT

Documentation

niconico API

Build Status Maintainability Test Coverage

Requirements

PHP >= 7.2

実装済み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->service('video')->search($query);

// returns array
$response = $search->service('video')->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