3v4l.org

run code in 300+ PHP versions simultaneously
<?php class instagram_story{ protected function file_get_contents_curl($url){ $cookies = dirname(__FILE__)."/auth.txt" ; $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, $url); curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($curl, CURLOPT_COOKIEFILE, $cookies); curl_setopt ($curl, CURLOPT_RETURNTRANSFER, true); $answer = curl_exec($curl); curl_close($curl); return $answer; } public function getStory($username){ $url = file_get_contents("https://www.instagram.com/$username/"); $json = '/sharedData\s=\s(.*[^\"]);<.script>/ixU'; preg_match_all($json, $url, $jsondata, PREG_SET_ORDER, 0); $array = json_decode($jsondata[0][1], true); $user_id = $array['entry_data']['ProfilePage']['0']['graphql']['user']['id']; $stories = $this->file_get_contents_curl("https://www.instagram.com/graphql/query/?query_hash=de8017ee0a7c9c45ec4260733d81ea31&variables=%7B%22reel_ids%22%3A%5B%22$user_id%22%5D%2C%22tag_names%22%3A%5B%5D%2C%22location_ids%22%3A%5B%5D%2C%22highlight_reel_ids%22%3A%5B%5D%2C%22precomposed_overlay%22%3Afalse%2C%22show_story_viewer_list%22%3Atrue%2C%22story_viewer_fetch_count%22%3A50%2C%22story_viewer_cursor%22%3A%22%22%7D"); $data = json_decode($stories, true); $stories = $data['data']['reels_media']['0']['items']; $_story = []; foreach ($stories as $story) { $vid = 'video_resources'; if (!array_key_exists($vid, $story)) { $_story [] = $story['display_url']; } else { $_story [] = $story['video_resources'][0]['src']; } } foreach ($_story as $story) { $check = '/mp4/m'; preg_match_all($check, $story, $matches, PREG_SET_ORDER, 0); if (empty($matches)) { echo "<a href=$story&dl=1><img src=$story></a>"; } else { echo '<video width="320" height="240" controls>'; echo '<source src="' . $story . '" type="video/mp4">'; echo '</video>'; echo "<a href=$story&dl=1>Download</a>"; } } } } // require_once 'class.instagram.php'; if (isset($_POST['submit'])) { $story = new instagram_story(); $story->getStory($_POST['username']); } ?> <div id="center" style="text-align: center; margin-top: 300px;"> <form action="http://storiesnab.com/page/loadmedia" method="post"> <input name="username"> <input type="submit" name="submit"> </form> </div>
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
<div id="center" style="text-align: center; margin-top: 300px;"> <form action="http://storiesnab.com/page/loadmedia" method="post"> <input name="username"> <input type="submit" name="submit"> </form> </div>
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 <div id="center" style="text-align: center; margin-top: 300px;"> <form action="http://storiesnab.com/page/loadmedia" method="post"> <input name="username"> <input type="submit" name="submit"> </form> </div>
Output for 5.2.3 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/0o1UN on line 23
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.2
<br /> <b>Parse error</b>: syntax error, unexpected '[' in <b>/in/0o1UN</b> on line <b>23</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.0.5
<br /> <b>Parse error</b>: parse error, unexpected '[' in <b>/in/0o1UN</b> on line <b>23</b><br />
Process exited with code 255.
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/0o1UN</b> on line <b>3</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/0o1UN</b> on line <b>3</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in <b>/in/0o1UN</b> on line <b>3</b><br />
Process exited with code 255.

preferences:
343.98 ms | 401 KiB | 468 Q