You are here

class InstagramUser in Drupagram 6

Same name and namespace in other branches
  1. 7 drupagram.lib.php \InstagramUser

Class for containing an individual Instagram user.

Hierarchy

Expanded class hierarchy of InstagramUser

1 string reference to 'InstagramUser'
Instagram::fetch in ./drupagram.lib.php
Get an array of Instagram objects from an API endpoint

File

./drupagram.lib.php, line 564
Classes to implement the full Instagram API

View source
class InstagramUser {
  public $id;
  public $username;
  public $first_name;
  public $last_name;
  public $full_name;
  public $profile_picture;
  public $bio;
  public $website;
  public $media_count;
  public $follows_count;
  public $followed_by_count;
  public $follows;
  public $followed_by;
  public $url;
  protected $password;
  protected $oauth_token;
  protected $oauth_token_secret;

  /**
   * Constructor for InstagramUser
   */
  public function __construct($values = array()) {
    if (!isset($values) || empty($values)) {
      return FALSE;
    }
    if (!is_array($values)) {
      $values = (array) $values;
    }
    $values = array_filter($values);
    foreach ($values as $key => $value) {
      switch ($key) {
        case 'counts':
          if (is_array($values['counts']) && !empty($values['counts'])) {
            $this->media_count = isset($values['counts']['media']) ? (int) $values['counts']['media'] : 0;
            $this->follows_count = isset($values['counts']['follows']) ? (int) $values['counts']['follows'] : 0;
            $this->followed_by_count = isset($values['counts']['followed_by']) ? (int) $values['counts']['followed_by'] : 0;
          }
          break;
        default:
          $this->{$key} = $value;
          break;
      }
    }
  }
  public function get_auth() {
    return array(
      'password' => $this->password,
      'oauth_token' => $this->oauth_token,
      'oauth_token_secret' => $this->oauth_token_secret,
    );
  }
  public function set_auth($values) {
    $this->oauth_token = isset($values['oauth_token']) ? $values['oauth_token'] : NULL;
    $this->oauth_token_secret = isset($values['oauth_token_secret']) ? $values['oauth_token_secret'] : NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
InstagramUser::$bio public property
InstagramUser::$first_name public property
InstagramUser::$followed_by public property
InstagramUser::$followed_by_count public property
InstagramUser::$follows public property
InstagramUser::$follows_count public property
InstagramUser::$full_name public property
InstagramUser::$id public property
InstagramUser::$last_name public property
InstagramUser::$media_count public property
InstagramUser::$oauth_token protected property
InstagramUser::$oauth_token_secret protected property
InstagramUser::$password protected property
InstagramUser::$profile_picture public property
InstagramUser::$url public property
InstagramUser::$username public property
InstagramUser::$website public property
InstagramUser::get_auth public function
InstagramUser::set_auth public function
InstagramUser::__construct public function Constructor for InstagramUser