From 680f1ae19af3de73c7fac2a6aa9f340a97e3992c Mon Sep 17 00:00:00 2001 From: Amaury Carrade Date: Mon, 23 Jul 2018 18:38:42 +0200 Subject: [PATCH 1/5] Fixed changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc49e0c..5f35e5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -#v1.1.0 +# v1.1.0 ## 11-07-2018 1. [](#new) From 039371e646afad869d56ec0ca27657816f94e234 Mon Sep 17 00:00:00 2001 From: Amaury Carrade Date: Tue, 14 Aug 2018 18:05:06 +0200 Subject: [PATCH 2/5] Version 1.1.1 + changelog (finally) --- CHANGELOG.md | 8 +++++++- blueprints.yaml | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc49e0c..c6e71cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ -#v1.1.0 +# v1.1.1 +## 14-08-2018 + +1. [](#bugfix) + * Fixed a regression where download options were no longer working since the per-network download options (oh the irony). + +# v1.1.0 ## 11-07-2018 1. [](#new) diff --git a/blueprints.yaml b/blueprints.yaml index 1275a38..e0a42e9 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,5 +1,5 @@ name: Static Social Embeds -version: 1.1.0 +version: 1.1.1 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. From 065a56a4beb4299fa5a886be4873d5ee52308733 Mon Sep 17 00:00:00 2001 From: Amaury Carrade Date: Tue, 14 Aug 2018 20:53:45 +0200 Subject: [PATCH 3/5] Fixed Instagram posts badly retrieved if Instagram redirects to another URL. (May happen if there is a missing trailing shash, for example.) --- CHANGELOG.md | 6 ++++++ blueprints.yaml | 2 +- shortcodes/InstagramShortcode.php | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) 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); From d3c145ad050fd5f06e084841b34574f2d320aaf7 Mon Sep 17 00:00:00 2001 From: Amaury Carrade Date: Thu, 23 Aug 2018 15:37:09 +0200 Subject: [PATCH 4/5] Fixed error while embedding non-existant Instagram post --- blueprints.yaml | 2 +- shortcodes/InstagramShortcode.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/blueprints.yaml b/blueprints.yaml index 3f5df0d..deecaef 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,5 +1,5 @@ name: Static Social Embeds -version: 1.1.2 +version: 1.1.3 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 4a195a6..7202e88 100644 --- a/shortcodes/InstagramShortcode.php +++ b/shortcodes/InstagramShortcode.php @@ -54,10 +54,17 @@ protected function getData($url) ]); $raw_instagram_html = curl_exec($ch); + $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $error_code = curl_errno($ch); $error = $error_code != 0 ? (': #' . $error_code . ' - ' . curl_error($ch)) : ''; + if (!$error && $http_code != 200) + { + $error = ': HTTP ' . $http_code . ($http_code == 404 ? ' - Not Found' : ''); + $raw_instagram_html = null; + } + curl_close($ch); if (!$raw_instagram_html) @@ -65,6 +72,9 @@ protected function getData($url) preg_match('/window\._sharedData = (.*);<\/script>/', $raw_instagram_html, $matches, PREG_OFFSET_CAPTURE, 0); + if (!$matches || count($matches) < 2 || count($matches[1]) < 1) + return ['errors' => [['code' => 0, 'message' => 'Unable to retrieve instagram post: cannot parse the web page to retrieve data.']], 'url' => $url]; + $post = json_decode($matches[1][0], true); if (!$post @@ -74,7 +84,7 @@ protected function getData($url) || !isset($post['entry_data']['PostPage'][0]['graphql']) || !isset($post['entry_data']['PostPage'][0]['graphql']['shortcode_media'])) { - return ['errors' => [['code' => 0, 'message' => 'Unable to retrieve instagram post']], 'url' => $url]; + return ['errors' => [['code' => 0, 'message' => 'Unable to retrieve instagram post: cannot parse the web page to retrieve data.']], 'url' => $url]; } // Instagram Post or Inner Post (as you like) From 8979e8570703c137b418fca05269db065a17e755 Mon Sep 17 00:00:00 2001 From: Amaury Carrade Date: Thu, 23 Aug 2018 15:40:28 +0200 Subject: [PATCH 5/5] Updated CHANGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9751d81..d63e6e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.1.3 +## 23-08-2018 + +1. [](#bugfix) + * Fixed error while embedding non-existant Instagram post. + # v1.1.2 ## 14-08-2018