From b132adb9038c0eae9b752756c7bcb441645de901 Mon Sep 17 00:00:00 2001 From: Yevgeny Tomenko Date: Tue, 26 Apr 2016 00:36:23 +0300 Subject: [PATCH] added get getMediaShortcode method --- Instagram/Core/Proxy.php | 15 +++++++++++++++ Instagram/Instagram.php | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Instagram/Core/Proxy.php b/Instagram/Core/Proxy.php index 22eb5dd..e97e331 100644 --- a/Instagram/Core/Proxy.php +++ b/Instagram/Core/Proxy.php @@ -273,6 +273,21 @@ public function getMedia( $id ) { return $response->getData(); } + /** + * Get media + * + * @param string $shortcode Media short code + * @return StdClass Returns the media data + * @access public + */ + public function getMediaShortCode( $shortcode ) { + $response = $this->apiCall( + 'get', + sprintf( '%s/media/shortcode/%s', $this->api_url, $shortcode ) + ); + return $response->getData(); + } + /** * Get tag * diff --git a/Instagram/Instagram.php b/Instagram/Instagram.php index a9829a5..530eb27 100644 --- a/Instagram/Instagram.php +++ b/Instagram/Instagram.php @@ -138,6 +138,18 @@ public function getMedia( $id ) { return $media; } + + /** + * Get media by its shortcode + * + * @param string $shortcode Instagram media shortcode + * @return mixed + */ + public function getMediaShortcode($shortcode) { + $media = new Media( $this->proxy->getMediaShortCode( $shortcode ), $this->proxy ); + return $media; + } + /** * Get Tag *