You are here

class Media in Instagram API 8

Class Media.

@package Drupal\instagram_api\Service

Hierarchy

  • class \Drupal\instagram_api\Service\Media

Expanded class hierarchy of Media

2 string references to 'Media'
instagram_api.info.yml in ./instagram_api.info.yml
instagram_api.info.yml
instagram_api.services.yml in ./instagram_api.services.yml
instagram_api.services.yml
1 service uses Media
instagram_api.media in ./instagram_api.services.yml
Drupal\instagram_api\Service\Media

File

src/Service/Media.php, line 12

Namespace

Drupal\instagram_api\Service
View source
class Media {

  /**
   * 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;
  }

  /**
   * Search for recent media in a given area.
   *
   * @param string $lat
   *   Lat.
   * @param string $lng
   *   Lng.
   * @param string $distance
   *   Dist.
   * @param bool $cacheable
   *   Cacheable.
   *
   * @return array|bool
   *   Response array.
   *   https://api.instagram.com/v1/media/search?lat=48.858844&lng=2.294351&access_token=ACCESS-TOKEN
   *
   * @see https://www.instagram.com/developer/endpoints/media/
   */
  public function mediaSearch($lat, $lng, $distance = 1, $cacheable = TRUE) {
    $response = $this->client
      ->request('media/search', [
      'lat' => $lat,
      'lng' => $lng,
      'distance' => $distance,
    ], $cacheable);
    if ($response) {
      return $response;
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Media::$client protected property Client.
Media::$loggerFactory protected property Logger Factory.
Media::mediaSearch public function Search for recent media in a given area.
Media::__construct public function Media constructor.