├── .gitignore
├── .env.example
├── fonts
└── instagram.otf
├── icon
├── instagram_128.png
├── instagram_16.png
├── instagram_256.png
├── instagram_32.png
└── instagram_64.png
├── composer.json
├── js
├── main.js
└── script.js
├── test.php
├── css
└── styles.css
├── .github
└── dependabot.yml
├── proxy.php
├── Instagram
├── Uri.php
├── Login.php
└── InstagramAPI.php
├── sw.js
├── manifest.json
├── ReadMe.md
├── index.php
├── instagram.php
└── image
└── instagram.svg
/.gitignore:
--------------------------------------------------------------------------------
1 | cookies.txt
2 | vendor/
3 | composer.lock
4 | .env
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | PROXY_HOST=""
2 | PROXY_PORT=""
3 | username=""
4 | password=""
--------------------------------------------------------------------------------
/fonts/instagram.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Incognito-Coder/Instagram-Tools/HEAD/fonts/instagram.otf
--------------------------------------------------------------------------------
/icon/instagram_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Incognito-Coder/Instagram-Tools/HEAD/icon/instagram_128.png
--------------------------------------------------------------------------------
/icon/instagram_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Incognito-Coder/Instagram-Tools/HEAD/icon/instagram_16.png
--------------------------------------------------------------------------------
/icon/instagram_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Incognito-Coder/Instagram-Tools/HEAD/icon/instagram_256.png
--------------------------------------------------------------------------------
/icon/instagram_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Incognito-Coder/Instagram-Tools/HEAD/icon/instagram_32.png
--------------------------------------------------------------------------------
/icon/instagram_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Incognito-Coder/Instagram-Tools/HEAD/icon/instagram_64.png
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "require": {
3 | "guzzlehttp/guzzle": "^7.9.2",
4 | "vlucas/phpdotenv": "^5.6"
5 | },
6 | "autoload": {
7 | "psr-4": {
8 | "InstagramPHP\\": "Instagram/"
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/js/main.js:
--------------------------------------------------------------------------------
1 | window.addEventListener('load', () => {
2 | if ('serviceWorker' in navigator) {
3 | navigator.serviceWorker.register('/sw.js', { scope: '/' })
4 | .then(reg => {
5 |
6 | reg.update();
7 |
8 | }).catch(err => console.log('SW registration FAIL:', err));
9 | }
10 | });
11 |
--------------------------------------------------------------------------------
/test.php:
--------------------------------------------------------------------------------
1 | safeLoad();
9 |
10 | if (file_exists('cookies.txt')) {
11 | unlink('cookies.txt');
12 | }
13 | //$session = new InstagramPHPLogin(new Client(), 'user', 'pass');
14 | $session = new InstagramPHPLogin(new Client(), $_ENV['username'], $_ENV['password']);
15 | $session->SessionLogin();
16 |
--------------------------------------------------------------------------------
/css/styles.css:
--------------------------------------------------------------------------------
1 | @font-face {
2 | font-family: Instagram;
3 | src: url("../fonts/instagram.otf") format("opentype");
4 | }
5 | .gradient-custom {
6 | /* fallback for old browsers */
7 | background: #e27228;
8 | /* Chrome 10-25, Safari 5.1-6 */
9 | background: -webkit-linear-gradient(to right, rgba(226, 114, 40, 1), rgba(231, 35, 129, 1));
10 | /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
11 | background: linear-gradient(to right, rgba(226, 114, 40, 1), rgba(231, 35, 129, 1))
12 | }
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5 |
6 | version: 2
7 | updates:
8 | - package-ecosystem: "composer" # See documentation for possible values
9 | directory: "/" # Location of package manifests
10 | schedule:
11 | interval: "daily"
12 |
--------------------------------------------------------------------------------
/proxy.php:
--------------------------------------------------------------------------------
1 | 'temp/' . ExtractFileName($file)]);
18 | }
19 |
20 | MediaProxy($media);
21 |
--------------------------------------------------------------------------------
/Instagram/Uri.php:
--------------------------------------------------------------------------------
1 | {
12 |
13 | self.skipWaiting();
14 |
15 | e.waitUntil(
16 | caches.open(cacheName).then(cache => {
17 | return cache.addAll(includeToCache);
18 | })
19 | );
20 | });
21 |
22 | /* Serve cached content when offline */
23 | self.addEventListener('fetch', e => {
24 | e.respondWith(
25 | caches.match(e.request).then(response => {
26 | return response || fetch(e.request);
27 | })
28 | );
29 | });
30 |
31 | self.addEventListener('activate', event => {
32 | // delete any caches that aren't in cacheName
33 | // which will get rid of version
34 | event.waitUntil(
35 | caches.keys().then(keys => Promise.all(
36 | keys.map(key => {
37 | if (cacheName !== key) {
38 | return caches.delete(key);
39 | }
40 | })
41 | )).then(() => {
42 | console.log(cacheName + ' now ready to handle fetches!');
43 | })
44 | );
45 | });
46 |
--------------------------------------------------------------------------------
/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "insta down",
3 | "short_name": "IGT",
4 | "start_url": "/",
5 | "background_color": "#6777ef",
6 | "description": "دانلود از اینستا",
7 | "display": "fullscreen",
8 | "theme_color": "#6777ef",
9 | "icons": [
10 | {
11 | "src": "icon/instagram_16.png",
12 | "sizes": "16x16",
13 | "type": "image/png",
14 | "purpose": "any"
15 | },
16 | {
17 | "src": "icon/instagram_32.png",
18 | "sizes": "32x32",
19 | "type": "image/png",
20 | "purpose": "any"
21 | },
22 | {
23 | "src": "icon/instagram_64.png",
24 | "sizes": "64x64",
25 | "type": "image/png",
26 | "purpose": "any"
27 | },
28 | {
29 | "src": "icon/instagram_128.png",
30 | "sizes": "128x128",
31 | "type": "image/png",
32 | "purpose": "any"
33 | },
34 | {
35 | "src": "icon/instagram_256.png",
36 | "sizes": "256x256",
37 | "type": "image/png",
38 | "purpose": "any"
39 | }
40 | ]
41 | }
--------------------------------------------------------------------------------
/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Instagram Basic Tools
2 | Little php class for Instagram Scrapping.\
3 | Telegram Bot Demo [@InstaTakerBot](https://t.me/InstaTakerBot) \
4 | **Note** : \
5 | _Don't forgot to set your own Coockie in Script._ [ **Deprecated** ]
6 |
7 | ```php
8 | $_COOKIE = '';
9 | ```
10 | ### Great News
11 | Since version 3.0 release you don't need to manually set cookies data, just login or run test.php file
12 | ```php
13 | SessionLogin();
21 | ```
22 | In version 4.0 you can set variables in `.env` file instead of php source code. \
23 | Here is your environment variable table:
24 |
25 | | Variable | Example Value | Description |
26 | | ---------- | ------------- | --------------------- |
27 | | PROXY_HOST | 127.0.0.1 | Proxy server hostname |
28 | | PROXY_PORT | 8080 | Proxy server port |
29 | | username | your_username | Instagram username |
30 | | password | your_password | Instagram password |
31 | ## Local Deploy
32 | First install [composer](https://getcomposer.org/) on your system,then run:
33 | ```bash
34 | composer install
35 | ```
36 | ```bash
37 | cd Instagram-Tools && php -S localhost:8000
38 | ```
39 | then open http://localhost:8000/ in browser,now you can use PWA in your local webserver.
40 | ## Main Features :
41 | * Return Account Info (Profile)
42 | * Download Media
43 | * Download Highlights
44 | * Download Reels
45 | * Download Story
46 | # Changes
47 |
48 | Click to see changelogs.
50 |
51 | ### v2.2
52 | * Now is be PWA
53 | ### v2.5
54 | * Sadly instagram fully closed previous ( **__a=1** ) method, so i used a newer one.
55 | ### v3.0
56 | * Completely object oriented
57 | * Codes rewrited from scratch
58 | * All requests are now handled over Guzzle
59 | * Fixed Highlight detection
60 | ### v3.2
61 | * Now PWA can play carousel photos and videos
62 | * some javascript bugs fixed
63 | ### v3.5
64 | Note: *this is final build for 2023*
65 | * Changed UserAgent somewhere
66 | * Fixed login CSRF data
67 | * Updated login ajax url
68 | * New regex pattern for getting **media id**
69 | * Bumped guzzle version to 7.8.1
70 | ### v3.6
71 | * Fixed story scapping
72 | * Some changes in Highlights regex pattern
73 | ### v3.7
74 | * Returning post play count
75 | * Bumped guzzle version to 7.9.2
76 | ### v3.8
77 | * Fix of regex in getReelsID func
78 | * Updated UserAgents
79 | ### v3.9
80 | * Update Instagram android useragent
81 | ### v4.0
82 | * Add proxy support and environment configuration for Instagram API
83 | * Some code improvments.
84 |
');
9 | document.getElementById("caption").hidden = false;
10 | if (isUnicode(document.getElementById('caption').textContent)) {
11 | document.getElementById('caption').style.direction = 'rtl';
12 | }
13 | else {
14 | document.getElementById('caption').style.direction = 'ltr';
15 | }
16 | }
17 | var data = new FormData();
18 | data.append("file", JData.file);
19 | var xhr = new XMLHttpRequest();
20 | xhr.addEventListener("readystatechange", function () {
21 | if (this.readyState === 4) {
22 | var json = JSON.parse(this.responseText);
23 | if (JData.type == 'image') {
24 | document.getElementById("thumb").hidden = false;
25 | document.getElementById("thumb").src = json.path;
26 | }
27 | }
28 | });
29 | xhr.open("POST", "proxy.php");
30 | xhr.send(data);
31 | if (JData.type == 'side') {
32 | var count = 0;
33 | document.getElementById("thumb").hidden = true;
34 | document.getElementById('carouselExampleControls').hidden = false;
35 | JData.data.forEach((element, index) => {
36 | let slide = document.createElement("div");
37 | if (index == 0) {
38 | slide.className = "carousel-item active";
39 | } else {
40 | slide.className = "carousel-item";
41 | }
42 | var data = new FormData();
43 | data.append("file", element.file);
44 | var xhr = new XMLHttpRequest();
45 | xhr.open("POST", "proxy.php");
46 | xhr.send(data);
47 | xhr.addEventListener("readystatechange", function () {
48 | if (this.readyState === 4) {
49 | var json = JSON.parse(this.responseText);
50 | if (element.type == "image") {
51 | slide.innerHTML = "";
52 | } else if (element.type == "video") {
53 | slide.innerHTML = "";
54 | }
55 | }
56 | });
57 | document.getElementById('carousel-child').appendChild(slide);
58 | let btn = document.createElement("a");
59 | btn.className = "btn p-1 m-1";
60 | btn.style.backgroundColor = "#00b0ff";
61 | btn.style.color = 'white';
62 | btn.innerHTML = " " + count++;
63 | btn.href = element.file;
64 | btn.target = '_blank';
65 | document.getElementById('files').appendChild(btn);
66 | });
67 | } else {
68 | let btn = document.createElement("a");
69 | btn.className = "btn p-1 m-1";
70 | btn.style.backgroundColor = "#00b0ff";
71 | btn.style.color = 'white';
72 | btn.innerHTML = " Save";
73 | btn.href = JData.file;
74 | btn.target = '_blank';
75 | document.getElementById('files').appendChild(btn);
76 | }
77 | }
78 | };
79 | xmlhttp.open("GET", "instagram.php?link=" + document.getElementById("url-field").value, true);
80 | xmlhttp.send();
81 | }
82 | function isUnicode(str) {
83 | var letters = [];
84 | for (var i = 0; i <= str.length; i++) {
85 | letters[i] = str.substring((i - 1), i);
86 | if (letters[i].charCodeAt() > 255) { return true; }
87 | }
88 | return false;
89 | }
--------------------------------------------------------------------------------
/index.php:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |