• 19-03-2023, 20:54:46
    #1
    function downloadFile($url) {
      // Instagram Video ve Fotoğraf İndirme
      if (preg_match('/instagram\.com\/(p|tv)\/([^\/]+)/', $url, $matches)) {
        $download_url = "https://www.instagram.com/{$matches[1]}/{$matches[2]}/media/?size=l";
        $extension = pathinfo($download_url, PATHINFO_EXTENSION);
        $folder = "instagram_" . ($extension == "mp4" ? "videos" : "photos");
      }
      // Instagram Hikaye İndirme
      elseif (preg_match('/instagram\.com\/stories\/([^\/]+)/', $url, $matches)) {
        $download_url = "https://www.instagram.com/stories/{$matches[1]}/?noscript=true";
        $extension = "jpg";
        $folder = "instagram_stories";
      }
      // Tiktok Video ve Fotoğraf İndirme
      elseif (preg_match('/tiktok\.com\/(@[^\/]+)\/(video\/\d+|image\/\d+)/', $url, $matches)) {
        $download_url = "https://www.tiktok.com/{$matches[1]}/{$matches[2]}";
        $extension = pathinfo($download_url, PATHINFO_EXTENSION);
        $folder = "tiktok_" . ($extension == "mp4" ? "videos" : "photos");
      }
      // Twitter Video ve Fotoğraf İndirme
      elseif (preg_match('/twitter\.com\/([^\/]+)\/status\/(\d+)/', $url, $matches)) {
        $html = file_get_contents($url);
        preg_match('/<meta property="og:image" content="([^"]+)"/', $html, $matches);
        $thumbnail_url = $matches[1];
        preg_match('/<meta property="og:video:url" content="([^"]+)"/', $html, $matches);
        $download_url = $matches[1];
        $extension = pathinfo($download_url, PATHINFO_EXTENSION);
        $folder = "twitter_" . ($extension == "mp4" ? "videos" : "photos");
      }
      // Facebook Video İndirme
      elseif (preg_match('/facebook\.com\/[^\/]+\/videos\/(\d+)/', $url, $matches)) {
        $download_url = "https://www.facebook.com/video/{$matches[1]}/";
        $html = file_get_contents($download_url);
        preg_match('/hd_src:"([^"]+)"/', $html, $matches);
        $download_url = $matches[1];
        $extension = "mp4";
        $folder = "facebook_videos";
      }
      // Diğer durumlar için hata ver
      else {
        die("Geçersiz URL");
      }
    
      if (!file_exists($folder)) {
        mkdir($folder, 0777, true);
      }
    
      // İndirme dosya yolu ve ismi
      $file_path = $folder."/".uniqid().'.'.$extension;
    
      // Dosyayı indir
      $file_contents = file_get_contents($download_url);
    
      // Dosyayı kaydet
      file_put_contents($file_path,$file_contents);
    
    // İndirme işlemi başarılıysa dosya yolu ve ismini geri döndür
    if ($file_contents !== false) {
    return $file_path;
    } else {
    die("Dosya indirilemedi");
    }
    }
    Kod çalışıyor da tiktok ve facebook çalışmıyor