You are here

class InstagramPost in Instagram Block 7

InstagramPost implementation class

Hierarchy

Expanded class hierarchy of InstagramPost

File

./instagram_block.lib.php, line 159
Instagram classes to integrate with the Instagram API.

View source
class InstagramPost {

  /**
   * @var string $id.
   */
  protected $id;

  /**
   * @var InstagramUser $user.
   */
  public $user;

  /**
   * @var string $created.
   */
  public $created;

  /**
   * @var string $type.
   */
  public $type;

  /**
   * @var string $link.
   */
  public $link;

  /**
   * @var InstagramLocation $location.
   */
  public $location;

  /**
   * @var InstagramComment $caption.
   */
  public $caption;

  /**
   * @var array $comments
   *   Array of InstagramComments.
   */
  public $comments;

  /**
   * @var integer $comment_count.
   */
  public $comment_count;

  /**
   * @var array $likes
   *   Array of InstagramLikes.
   */
  public $likes;

  /**
   * @var array $images
   *   Array of Image links.
   */
  public $images;

  /**
   * @var integer $like_count.
   */
  public $like_count;

  /**
   * Constructor for the InstagramPost class
   */
  public function __construct($instagram_post) {
    $this->id = $instagram_post->id;
    $this->user = new InstagramUser($instagram_post->user);
    $this->created = $instagram_post->created_time;
    $this->type = $instagram_post->type;
    $this->link = $instagram_post->link;
    $this->images = $instagram_post->images;
    if (!empty($instagram_post->location)) {
      $this->location = new InstagramLocation($instagram_post->location);
    }
    if (!empty($instagram_post->caption)) {
      $this->caption = new InstagramComment($instagram_post->caption);
    }
    if ($instagram_post->comments->count && !empty($instagram_post->comments->data)) {
      $this->comment_count = $instagram_post->comments->count;
      $this->comments = $this
        ->get_comments($instagram_post->comments->data);
    }
    if ($instagram_post->likes->count && !empty($instagram_post->likes->data)) {
      $this->like_count = $instagram_post->likes->count;
      $this->likes = $this
        ->get_likes($instagram_post->likes->data);
    }
  }

  /**
   * Builds an InstagramComment.
   */
  protected function get_comments($data) {
    $comments = array();
    foreach ($data as $comment) {
      $comments[] = new InstagramComment($comment);
    }
    return $comments;
  }

  /**
   * Builds an InstagramLike.
   */
  protected function get_likes($data) {
    $likes = array();
    foreach ($data as $like) {
      $likes[] = new InstagramLike($like);
    }
    return $likes;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
InstagramPost::$caption public property
InstagramPost::$comments public property Array of InstagramComments.
InstagramPost::$comment_count public property
InstagramPost::$created public property
InstagramPost::$id protected property
InstagramPost::$images public property Array of Image links.
InstagramPost::$likes public property Array of InstagramLikes.
InstagramPost::$like_count public property
InstagramPost::$link public property
InstagramPost::$location public property
InstagramPost::$type public property
InstagramPost::$user public property
InstagramPost::get_comments protected function Builds an InstagramComment.
InstagramPost::get_likes protected function Builds an InstagramLike.
InstagramPost::__construct public function Constructor for the InstagramPost class