You are here

class Users in Instagram API 8

Class Users.

@package Drupal\instagram_api\Service

Hierarchy

  • class \Drupal\instagram_api\Service\Users

Expanded class hierarchy of Users

1 string reference to 'Users'
instagram_api.services.yml in ./instagram_api.services.yml
instagram_api.services.yml
1 service uses Users
instagram_api.users in ./instagram_api.services.yml
Drupal\instagram_api\Service\Users

File

src/Service/Users.php, line 12

Namespace

Drupal\instagram_api\Service
View source
class Users {

  /**
   * Client.
   *
   * @var \Drupal\instagram_api\Service\Client
   */
  protected $client;

  /**
   * Logger Factory.
   *
   * @var \Drupal\Core\Logger\LoggerChannelFactoryInterface
   */
  protected $loggerFactory;

  /**
   * Media constructor.
   *
   * @param \Drupal\instagram_api\Service\Client $client
   *   Client.
   * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerFactory
   *   LoggerChannelFactory.
   */
  public function __construct(Client $client, LoggerChannelFactoryInterface $loggerFactory) {

    // Instagram API Client.
    $this->client = $client;
    $this->loggerFactory = $loggerFactory;
  }

  /**
   * Get information about the owner of the access_token.
   *
   * @param bool $cacheable
   *   Cacheable.
   *
   * @return array|bool
   *   Response array.
   *   https://api.instagram.com/v1/users/self/?access_token=ACCESS-TOKEN
   *
   * @see https://www.instagram.com/developer/endpoints/users/#get_users_self
   */
  public function getSelf($cacheable = TRUE) {
    $response = $this->client
      ->request('users/self', [], $cacheable);
    if ($response) {
      return $response;
    }
    return FALSE;
  }

  /**
   * Get the most recent media published by the owner of the access_token.
   *
   * @param array $args
   *   Args, see API docs for options.
   * @param bool $cacheable
   *   Cacheable.
   *
   * @return array|bool
   *   Response array.
   *   https://api.instagram.com/v1/users/self/?access_token=ACCESS-TOKEN
   *
   * @see https://www.instagram.com/developer/endpoints/users/#get_users_self
   */
  public function getSelfMediaRecent(array $args = [], $cacheable = TRUE) {
    $response = $this->client
      ->request('users/self/media/recent', $args, $cacheable);
    if ($response) {
      return $response;
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Users::$client protected property Client.
Users::$loggerFactory protected property Logger Factory.
Users::getSelf public function Get information about the owner of the access_token.
Users::getSelfMediaRecent public function Get the most recent media published by the owner of the access_token.
Users::__construct public function Media constructor.