PHP+ニコニコ動画API クラスの作成

ニコニコ動画APIで取得した情報を入れるためのクラスを作ります。

使用する時はnew演算子でインスタンス化します。

$nicoVideo_detail = new getthumbInfo();

nico_class.php

<?php

// getthumbInfoで得た情報を格納するクラス
Class getthumbInfo {
  private $video_id="";
  private $title = "";
  private $description = "";
  private $thumbnail_url = "";
  private $first_retrieve = "";
  private $length = "";
  private $view_counter = "";
  private $comment_num = "";
  private $mylist_counter = "";
  private $last_res_body = "";
  private $watch_url = "";
  private $thumb_type = "";
  private $embeddable = "";
  private $tags = "";

  // タブ区切りで全ての変数を返す
  public function toString() {
    return (string) (
      $this->video_id . "\t" . 
      $this->title . "\t" . 
      $this->description . "\t" . 
      $this->thumbnail_url . "\t" . 
      $this->first_retrieve . "\t" . 
      $this->length . "\t" . 
      $this->view_counter . "\t" . 
      $this->comment_num . "\t" . 
      $this->mylist_counter . "\t" . 
      $this->last_res_body . "\t" . 
      $this->watch_url . "\t" . 
      $this->thumb_type . "\t" . 
      $this->embeddable . "\t" . 
      $this->tags
    );
  }

  // video_id(video_id)を返す
  public function getVideo_id() {
    return $this->video_id;
  }
  // video_id(video_id)を設定
  public function setVideo_id($video_id) {
    $this->video_id = $video_id;
  }
  // タイトル(title)を返す
  public function getTitle() {
    return $this->title;
  }
  // タイトル(title)を設定
  public function setTitle($title) {
    $this->title = $title;
  }
  // 動画説明文(description)を返す
  public function getDescription() {
    return $this->description;
  }
  // 動画説明文(description)を設定
  public function setDescription($description) {
    $this->description = $description;
  }
  // サムネイル画像のURL(thumbnail_url)を返す
  public function getThumbnail_url() {
    return $this->thumbnail_url;
  }
  // サムネイル画像のURL(thumbnail_url)を設定
  public function setThumbnail_url($thumbnail_url) {
    $this->thumbnail_url = $thumbnail_url;
  }
  // 投稿日時(first_retrieve)を返す
  public function getFirst_retrieve() {
    return $this->first_retrieve;
  }
  // 投稿日時(first_retrieve)を設定
  public function setFirst_retrieve($first_retrieve) {
    $this->first_retrieve = $first_retrieve;
  }
  // 
  public function getLength() {
    return $this->length;
  }
  // 
  public function setLength($length) {
    $this->length = $length;
  }
  // 
  public function getView_counter() {
    return $this->view_counter;
  }
  // 
  public function setView_counter($view_counter) {
    $this->view_counter = $view_counter;
  }
  // 
  public function getComment_num() {
    return $this->comment_num;
  }
  // 
  public function setComment_num($comment_num) {
    $this->comment_num = $comment_num;
  }
  // 
  public function getMylist_counter() {
    return $this->mylist_counter;
  }
  // 
  public function setMylist_counter($mylist_counter) {
    $this->mylist_counter = $mylist_counter;
  }
  // 最新コメント(last_res_body)を返す
  public function getLast_res_body() {
    return $this->last_res_body;
  }
  // 最新コメント(last_res_body)を設定
  public function setLast_res_body($last_res_body) {
    $this->last_res_body = $last_res_body;
  }
  // 視聴URL(watch_url)を返す
  public function getWatch_url() {
    return $this->watch_url;
  }
  // 視聴URL(watch_url)を設定
  public function setWatch_url($watch_url) {
    $this->watch_url = $watch_url;
  }
  // 動画ならVideo、マイメモリーならmymemoryを返す
  public function getThumb_type() {
    return $this->thumb_type;
  }
  // 
  public function setThumb_type($thumb_type) {
    $this->thumb_type = $thumb_type;
  }
  // 
  public function getEmbeddable() {
    return $this->embeddable;
  }
  // 
  public function setEmbeddable($embeddable) {
    $this->embeddable = $embeddable;
  }
  // 設定タグ一覧(tags)を返す
  public function getTags() {
    return $this->tags;
  }
  // 設定タグ一覧(tags)を設定
  public function setTags($tags) {
    $this->tags = $tags;
  }
}

?>