We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents b7f9791 + a2c8bb5 commit a3a6921Copy full SHA for a3a6921
src/Shortcodes/TwitterShortcode.php
@@ -27,13 +27,18 @@ public function register($shortcode): string
27
28
private static function getOembed(string $url): ?string
29
{
30
- curl_setopt_array($curl = curl_init(), [
31
- CURLOPT_URL => "https://publish.twitter.com/oembed?url=$url&omit_script=1",
32
- CURLOPT_RETURNTRANSFER => true,
33
- ]);
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_URL, 'https://publish.twitter.com/oembed?url='.urlencode($url).'&omit_script=1');
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
34
$response = curl_exec($curl);
35
curl_close($curl);
36
37
- return json_decode($response)->html ?? null;
+ if ($response === false) {
+ return null;
38
+ }
39
+
40
+ $data = json_decode($response, true);
41
42
+ return $data['html'] ?? null;
43
}
44
0 commit comments