You are here

class Comments in Instagram API 8

Class Comments.

@package Drupal\instagram_api\Service

Hierarchy

  • class \Drupal\instagram_api\Service\Comments

Expanded class hierarchy of Comments

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

File

src/Service/Comments.php, line 12

Namespace

Drupal\instagram_api\Service
View source
class Comments {

  /**
   * 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 a list of recent comments on your media object.
   *
   * @param string $mediaId
   *   Media ID.
   * @param bool $cacheable
   *   Cacheable.
   *
   * @return array|bool
   *   Response array.
   *   https://api.instagram.com/v1/media/{media-id}/comments?access_token=ACCESS-TOKEN
   *
   * @see https://www.instagram.com/developer/endpoints/media/
   */
  public function getComments($mediaId, $cacheable = TRUE) {
    $response = $this->client
      ->request('media/' . $mediaId . '/comments', [], $cacheable);
    if ($response) {
      return $response;
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Comments::$client protected property Client.
Comments::$loggerFactory protected property Logger Factory.
Comments::getComments public function Get a list of recent comments on your media object.
Comments::__construct public function Media constructor.