Skip to content

Commit 065a56a

Browse files
committed
Fixed Instagram posts badly retrieved if Instagram redirects to another URL.
(May happen if there is a missing trailing shash, for example.)
1 parent b6db87d commit 065a56a

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v1.1.2
2+
## 14-08-2018
3+
4+
1. [](#bugfix)
5+
* Fixed Instagram posts failing to be retrieved in some cases.
6+
17
# v1.1.1
28
## 14-08-2018
39

blueprints.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Static Social Embeds
2-
version: 1.1.1
2+
version: 1.1.2
33
description: |
44
Embeds social status (like tweets, instagram posts, toots, etc.) in articles without using their embed iframe,
55
but rather statically without any dependency to the service.

shortcodes/InstagramShortcode.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,20 @@ protected function getData($url)
4848
curl_setopt_array($ch, [
4949
CURLOPT_TIMEOUT => 3600,
5050
CURLOPT_URL => $url,
51+
CURLOPT_FOLLOWLOCATION => true,
5152
CURLOPT_RETURNTRANSFER => true,
5253
CURLOPT_SSL_VERIFYPEER => false
5354
]);
5455

5556
$raw_instagram_html = curl_exec($ch);
5657

58+
$error_code = curl_errno($ch);
59+
$error = $error_code != 0 ? (': #' . $error_code . ' - ' . curl_error($ch)) : '';
60+
5761
curl_close($ch);
5862

5963
if (!$raw_instagram_html)
60-
return ['errors' => [['code' => 0, 'message' => 'Unable to retrieve instagram post']], 'url' => $url];
64+
return ['errors' => [['code' => 0, 'message' => 'Unable to retrieve instagram post' . $error]], 'url' => $url];
6165

6266
preg_match('/window\._sharedData = (.*);<\/script>/', $raw_instagram_html, $matches, PREG_OFFSET_CAPTURE, 0);
6367

0 commit comments

Comments
 (0)