Coder Social home page Coder Social logo

pareshsojitra / instagramdownload Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shico007/instagramdownload

0.0 1.0 0.0 69 KB

Instagram image and video downloader with URL validation and cURL integration

Home Page: https://downloadgram.com

License: MIT License

PHP 100.00%

instagramdownload's Introduction

Travis

Instagram Photo and video download helper library.

New: Checkout TikTokOff - TikTok video online downloader (no watermarks)

Update on May 22, 2020: Due to Instagram no longer allowing anonymous users to view photos/videos, this library is currently not working. A new version 7 is in the works, but there is no ETA yet. Only IGTV videos are working now

Old and unsupported versions

Old and minimally supported versions

I wrote this class mainly for my online Instagram photo, video and IGTV downloader, but I thought share this piece for your own extensions.

  • Validates Instagram URL (domain validation, URL path validation).
  • Uses OG properties to detect the image and video URL.
  • Supports Instagram photos, videos, and Instagram TV videos
  • Verbose error reporting with proper exceptions.
  • Full unit tests
  • No dependencies other than PHP curl extension (which is most likely enabled by already)

Requirements

  • PHP 7.4
  • Curl

Thanks to:

  • MetaData - Meta data parsing regex and curl class.

Installation

With composer Install the library by running the following in your project.

composer require ayesh/instagram-download

Without composer Download the zip file from Github, and configure your autoload handler to autoload PSR-4 Ayesh\InstagramDownload namespace from the downloaded contents src directory.

You could also manually require the file. Requires a certain amount of guilty feeling because it's 2017 and you are not using a decent autoload mechanism.

require_once 'src/InstagramDownload.php'

Usage

<?php
use Ayesh\InstagramDownload\InstagramDownload;
$url = 'http://instagram.com/p/tmwAlCGygb/';

try {
  $client = new InstagramDownload($url);
  $url = $client->getDownloadUrl(); // Returns the download URL.
  $type = $client->getType(); // Returns "image" or "video" depending on the media type.
}
catch (\InvalidArgumentException $exception) {
  /*
   * \InvalidArgumentException exceptions will be thrown if there is a validation 
   * error in the URL. You might want to break the code flow and report the error 
   * to your form handler at this point.
   */
  $error = $exception->getMessage();
}
catch (\RuntimeException $exception) {
  /*
   * \RuntimeException exceptions will be thrown if the URL could not be 
   * fetched, parsed, or a media could not be extracted from the URL. 
   */
  $error = $exception->getMessage();
}

instagramdownload's People

Contributors

ayesh avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.