diff --git a/CHANGELOG.md b/CHANGELOG.md index c6e71cf..9751d81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.1.2 +## 14-08-2018 + +1. [](#bugfix) + * Fixed Instagram posts failing to be retrieved in some cases. + # v1.1.1 ## 14-08-2018 diff --git a/blueprints.yaml b/blueprints.yaml index e0a42e9..3f5df0d 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,5 +1,5 @@ name: Static Social Embeds -version: 1.1.1 +version: 1.1.2 description: | Embeds social status (like tweets, instagram posts, toots, etc.) in articles without using their embed iframe, but rather statically without any dependency to the service. diff --git a/shortcodes/InstagramShortcode.php b/shortcodes/InstagramShortcode.php index 48b1dd0..4a195a6 100644 --- a/shortcodes/InstagramShortcode.php +++ b/shortcodes/InstagramShortcode.php @@ -48,16 +48,20 @@ protected function getData($url) curl_setopt_array($ch, [ CURLOPT_TIMEOUT => 3600, CURLOPT_URL => $url, + CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false ]); $raw_instagram_html = curl_exec($ch); + $error_code = curl_errno($ch); + $error = $error_code != 0 ? (': #' . $error_code . ' - ' . curl_error($ch)) : ''; + curl_close($ch); if (!$raw_instagram_html) - return ['errors' => [['code' => 0, 'message' => 'Unable to retrieve instagram post']], 'url' => $url]; + return ['errors' => [['code' => 0, 'message' => 'Unable to retrieve instagram post' . $error]], 'url' => $url]; preg_match('/window\._sharedData = (.*);<\/script>/', $raw_instagram_html, $matches, PREG_OFFSET_CAPTURE, 0);