Loading src/Plugin/Block/InstagramWithoutApi.php +13 −5 Original line number Diff line number Diff line Loading @@ -100,12 +100,20 @@ class InstagramWithoutApi extends BlockBase { $url = "https://www.instagram.com/{$this->configuration['name']}"; try { // Get Response file_get_contents($url); $instagram_url = \Drupal::httpClient()->get($url); $response = (string) $instagram_url->getBody(); } catch (\Exception $e) { \Drupal::logger('instagram_without_api')->error($e->getMessage()); } if (empty($response)) { //Can't find Url return []; // Can't find Url. Return a message letting user know what is the problem. return [ '#markup' => 'Could not reach Instagram server', ]; } // the start position Loading Loading
src/Plugin/Block/InstagramWithoutApi.php +13 −5 Original line number Diff line number Diff line Loading @@ -100,12 +100,20 @@ class InstagramWithoutApi extends BlockBase { $url = "https://www.instagram.com/{$this->configuration['name']}"; try { // Get Response file_get_contents($url); $instagram_url = \Drupal::httpClient()->get($url); $response = (string) $instagram_url->getBody(); } catch (\Exception $e) { \Drupal::logger('instagram_without_api')->error($e->getMessage()); } if (empty($response)) { //Can't find Url return []; // Can't find Url. Return a message letting user know what is the problem. return [ '#markup' => 'Could not reach Instagram server', ]; } // the start position Loading