From 51a7705bf7eb79e1a1bf87008cdd0d2d29ccaab5 Mon Sep 17 00:00:00 2001 From: ThomasBolander Date: Thu, 9 Jun 2016 14:11:45 +0200 Subject: [PATCH] Added return type --- composer.json | 2 +- src/Instagram.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index f3ef3c3..57d8d7c 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "email": "privat@thomasbolander.dk" } ], - "version": "1.0.1", + "version": "1.0.2", "autoload": { "psr-4": {"Bolandish\\": "src/"} } diff --git a/src/Instagram.php b/src/Instagram.php index 0f0aa4a..5102083 100644 --- a/src/Instagram.php +++ b/src/Instagram.php @@ -2,7 +2,7 @@ namespace Bolandish; class Instagram { - public static function getMediaByHashtag($hashtag = null, $count = 16) + public static function getMediaByHashtag($hashtag = null, $count = 16, $return_type = "object") { if ( empty($hashtag) || !is_string($hashtag) ) { @@ -11,12 +11,12 @@ public static function getMediaByHashtag($hashtag = null, $count = 16) $hashtag = strtolower($hashtag); $parameters = urlencode("ig_hashtag($hashtag) { media.first($count) { count, nodes { caption, code, comments { count }, date, dimensions { height, width }, display_src, id, is_video, likes { count }, owner { id, username }, thumbnail_src, video_views, video_url }, page_info } }"); $url = "https://www.instagram.com/query/?q=$parameters&ref=tags%3A%3Ashow"; - $media = json_decode(file_get_contents($url)); + $media = json_decode(file_get_contents($url), ($return_type == "array")); $media = $media->media->nodes; return $media; } - public static function getMediaByUserID($user = null, $count = 16) + public static function getMediaByUserID($user = null, $count = 16, $return_type = "object") { if ( empty($user) || !(is_string($user) || is_int($user)) ) { @@ -24,12 +24,12 @@ public static function getMediaByUserID($user = null, $count = 16) } $parameters = urlencode("ig_user($user) { media.first($count) { count, nodes { caption, code, comments { count }, date, dimensions { height, width }, display_src, id, is_video, likes { count }, owner { id, username }, thumbnail_src, video_views, video_url }, page_info } }"); $url = "https://www.instagram.com/query/?q=$parameters&ref=tags%3A%3Ashow"; - $media = json_decode(file_get_contents($url)); + $media = json_decode(file_get_contents($url),($return_type == "array")); $media = $media->media->nodes; return $media; } - public static function getMediaAfterByUserID($user = null,$min_id, $count = 16) + public static function getMediaAfterByUserID($user = null,$min_id, $count = 16, $return_type = "object") { if ( empty($user) || !(is_string($user) || is_int($user)) ) { @@ -37,7 +37,7 @@ public static function getMediaAfterByUserID($user = null,$min_id, $count = 16) } $parameters = urlencode("ig_user($user) { media.after($min_id,$count) { count, nodes { caption, code, comments { count }, date, dimensions { height, width }, display_src, id, is_video, likes { count }, owner { id, username }, thumbnail_src, video_views, video_url }, page_info } }"); $url = "https://www.instagram.com/query/?q=$parameters&ref=tags%3A%3Ashow"; - $media = json_decode(file_get_contents($url)); + $media = json_decode(file_get_contents($url),($return_type == "array")); $media = $media->media->nodes; return $media; }