Advertisement
Guest User

Untitled

a guest
May 29th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. <?php
  2.  
  3. $profile = $_GET['profile'];
  4.  
  5.     $default_redirect_link = "http://instagram.com";
  6.  
  7.     $ch = curl_init("https://www.instagram.com/".$profile."/");
  8.     curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  9.     curl_setopt ($ch, CURLOPT_TIMEOUT, 10);
  10.     curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 10);
  11.     curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
  12.     curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
  13.     curl_setopt ($ch, CURLOPT_HTTPHEADER, array(
  14.         'user-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36',
  15.     ));
  16.  
  17.     $data = curl_exec($ch);
  18.  
  19.     curl_close ($ch);
  20.  
  21.     $data = explode(";</script>", explode("window._sharedData = ", $data)[1])[0];
  22.  
  23.     if($data[0] == "{"){
  24.  
  25.         $json_data = json_decode($data);
  26.  
  27.         $external_url = $json_data->entry_data->ProfilePage[0]->graphql->user->external_url;
  28.  
  29.         if($external_url != null){
  30.             header("Location: ".$external_url);
  31.         }else{
  32.             header("Location: ".$default_redirect_link);
  33.         }
  34.     }else{
  35.         header("Location: ".$default_redirect_link);
  36.     }
  37.  
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement