From 26f0380aaa281cc3a50a4b6af253116427a74527 Mon Sep 17 00:00:00 2001 From: mw80 <19948946+mw80@users.noreply.github.com> Date: Wed, 23 Mar 2022 04:09:59 +0100 Subject: [PATCH] [InstagramBridge] Add detectParameters (#1476) --- bridges/InstagramBridge.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bridges/InstagramBridge.php b/bridges/InstagramBridge.php index 910e5606..4e03c352 100644 --- a/bridges/InstagramBridge.php +++ b/bridges/InstagramBridge.php @@ -55,6 +55,12 @@ class InstagramBridge extends BridgeAbstract { ); + const TEST_DETECT_PARAMETERS = array( + 'https://www.instagram.com/metaverse' => array('u' => 'metaverse'), + 'https://instagram.com/metaverse' => array('u' => 'metaverse'), + 'http://www.instagram.com/metaverse' => array('u' => 'metaverse'), + ); + const USER_QUERY_HASH = '58b6785bea111c67129decbe6a448951'; const TAG_QUERY_HASH = '9b498c08113f1e09617a1703c22b2f32'; const SHORTCODE_QUERY_HASH = '865589822932d1b43dfe312121dd353a'; @@ -278,4 +284,18 @@ class InstagramBridge extends BridgeAbstract { } return parent::getURI(); } + + public function detectParameters($url){ + $params = array(); + + // By username + $regex = '/^(https?:\/\/)?(www\.)?instagram\.com\/([^\/?\n]+)/'; + + if(preg_match($regex, $url, $matches) > 0) { + $params['u'] = urldecode($matches[3]); + return $params; + } + + return null; + } }