├── .gitignore ├── composer.json ├── LICENSE ├── instagram-cache-byid.json ├── instagram-cache-byidurl.json ├── how-to-show-base64-images.html ├── instagram-cache-bytag.json ├── test.php ├── README.md └── src └── InstagramWithoutApi.php /.gitignore: -------------------------------------------------------------------------------- 1 | composer.lock 2 | vendor/ 3 | 4 | # Numerous always-ignore extensions 5 | *.diff 6 | *.err 7 | *.orig 8 | *.log 9 | *.rej 10 | *.swo 11 | *.swp 12 | *.vi 13 | *~ 14 | *.sass-cache 15 | node_modules/ 16 | .tmp/ 17 | 18 | # OS or Editor folders 19 | .DS_Store 20 | Thumbs.db 21 | .cache 22 | .project 23 | .settings 24 | .tmproj 25 | *.esproj 26 | nbproject 27 | *.sublime-project 28 | *.sublime-workspace 29 | *.komodoproject 30 | .komodotools 31 | _notes 32 | dwsync.xml -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "orsifrancesco/instagram-without-api", 3 | "description": "A simple PHP code to get unlimited instagram public pictures (users and tags) without api, without credentials (just token from cookies), just Instagram Scraping (with cookie and image data in base64).", 4 | "keywords": [ 5 | "instagram", 6 | "api" 7 | ], 8 | "homepage": "https://github.com/orsifrancesco/instagram-without-api", 9 | "license": "MIT", 10 | "authors": [ 11 | { 12 | "name": "Francesco Orsi", 13 | "homepage": "https://orsi.me" 14 | } 15 | ], 16 | "require": { 17 | "php": ">=5.6.0", 18 | "ext-curl": "*", 19 | "ext-json": "*" 20 | }, 21 | "autoload": { 22 | "psr-0": { 23 | "InstagramWithoutApi": "src/" 24 | } 25 | }, 26 | "extra": { 27 | "branch-alias": { 28 | "dev-master": "1.0-dev" 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Francesco Orsi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /instagram-cache-byid.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "2890411760684296309", 4 | "width": 1440, 5 | "height": 1800, 6 | "imageUrl": "https:\/\/scontent-lhr8-2.cdninstagram.com\/v\/t51.2885-15\/295725943_735035624447654_1473541293876894507_n.jpg?stp=dst-jpg_e35&_nc_ht=scontent-lhr8-2.cdninstagram.com&_nc_cat=102&_nc_ohc=KJEy56SSk1MAX-uhQLO&edm=ALQROFkBAAAA&ccb=7-5&ig_cache_key=Mjg5MDQxMTc1NjY3NDU5MDM3Nw%3D%3D.2-ccb7-5&oh=00_AfAnHPV-f28J150wMRx5MqDxDvACjgGVNrRmWsLQesUisw&oe=644AC0DD&_nc_sid=30a2ef", 7 | "time": 1658783954, 8 | "topLikers": [ 9 | "isabellatkw" 10 | ], 11 | "likes": 72, 12 | "commentCount": 0, 13 | "comments": false, 14 | "link": "https:\/\/www.instagram.com\/p\/Cgczi6qMuh1\/", 15 | "text": "#sangimignano #sangiminiano #gimignano #tuscany #toscana #italy #italia #towers #memory #wonderfulplaces #worldtraveler #travelpic #traveller #instatravel #travelinggram #photographersofinstagram #travelphotos #traveldreamseeker #theculturetrip #escape #theglobewanderer #backpackerstory #travelbloggers #explore #vacation #town #traditional", 16 | "user": { 17 | "username": "orsifrancesco", 18 | "fullName": "Francesco Orsi", 19 | "imageUrl": "https:\/\/scontent-lhr8-1.cdninstagram.com\/v\/t51.2885-19\/293633624_167105452492883_7626123331007783257_n.jpg?stp=dst-jpg_s150x150&_nc_ht=scontent-lhr8-1.cdninstagram.com&_nc_cat=111&_nc_ohc=edGvTOiqDakAX8i2WX_&edm=ALQROFkBAAAA&ccb=7-5&oh=00_AfANXErFkX6ceImQLMfIVxElza9WfGpotWd7JamkEz7eXg&oe=644C3035&_nc_sid=30a2ef" 20 | } 21 | } 22 | ] -------------------------------------------------------------------------------- /instagram-cache-byidurl.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "2890411760684296309", 4 | "width": 1440, 5 | "height": 1800, 6 | "imageUrl": "https:\/\/scontent-lhr8-2.cdninstagram.com\/v\/t51.2885-15\/295725943_735035624447654_1473541293876894507_n.jpg?stp=dst-jpg_e35&_nc_ht=scontent-lhr8-2.cdninstagram.com&_nc_cat=102&_nc_ohc=KJEy56SSk1MAX-uhQLO&edm=ALQROFkBAAAA&ccb=7-5&ig_cache_key=Mjg5MDQxMTc1NjY3NDU5MDM3Nw%3D%3D.2-ccb7-5&oh=00_AfAnHPV-f28J150wMRx5MqDxDvACjgGVNrRmWsLQesUisw&oe=644AC0DD&_nc_sid=30a2ef", 7 | "time": 1658783954, 8 | "topLikers": [ 9 | "isabellatkw" 10 | ], 11 | "likes": 72, 12 | "commentCount": 0, 13 | "comments": false, 14 | "link": "https:\/\/www.instagram.com\/p\/Cgczi6qMuh1\/", 15 | "text": "#sangimignano #sangiminiano #gimignano #tuscany #toscana #italy #italia #towers #memory #wonderfulplaces #worldtraveler #travelpic #traveller #instatravel #travelinggram #photographersofinstagram #travelphotos #traveldreamseeker #theculturetrip #escape #theglobewanderer #backpackerstory #travelbloggers #explore #vacation #town #traditional", 16 | "user": { 17 | "username": "orsifrancesco", 18 | "fullName": "Francesco Orsi", 19 | "imageUrl": "https:\/\/scontent-lhr8-1.cdninstagram.com\/v\/t51.2885-19\/293633624_167105452492883_7626123331007783257_n.jpg?stp=dst-jpg_s150x150&_nc_ht=scontent-lhr8-1.cdninstagram.com&_nc_cat=111&_nc_ohc=edGvTOiqDakAX8i2WX_&edm=ALQROFkBAAAA&ccb=7-5&oh=00_AfANXErFkX6ceImQLMfIVxElza9WfGpotWd7JamkEz7eXg&oe=644C3035&_nc_sid=30a2ef" 20 | } 21 | } 22 | ] -------------------------------------------------------------------------------- /how-to-show-base64-images.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Base64 Example 5 | 6 | 44 | 45 | 46 | 47 | 48 | 49 |

IMG tag

50 |
51 | 52 |
53 | 54 |

CSS background-image

55 |
56 | 57 |
58 | 59 |

* data from 60 | 61 | instagram-cache.json 63 | 64 |

65 | 66 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /instagram-cache-bytag.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "3088161710839122178_22121685082", 4 | "time": 1682357585, 5 | "imageUrl": "https:\/\/scontent-lhr8-1.cdninstagram.com\/v\/t39.30808-6\/343433059_1905627053132288_8190203024140367177_n.jpg?stp=dst-jpg_e15_s750x750&_nc_ht=scontent-lhr8-1.cdninstagram.com&_nc_cat=108&_nc_ohc=9wv-S6ERzyIAX-vcOnM&edm=AGyKU4gAAAAA&ccb=7-5&ig_cache_key=MzA4ODE2MTcxMDgzOTEyMjE3OA%3D%3D.2-ccb7-5&oh=00_AfDilwL2leCdTjRdkznb8np9WcmDnNfOS5IFhfTGy-qdQw&oe=644B0C36&_nc_sid=4cb768", 6 | "link": "https:\/\/www.instagram.com\/p\/CrbWrbXh0kC\/", 7 | "text": "Follow me \n@indo_news7\n\n#jokowi #jokowidodo #jokowiorangnyabaik #indonesia #patriotgaruda #Puasa #Ramadhan #sahur #india \n#love #instagood #photography #photooftheday #travel #nature #instagram #picoftheday \n#incredibleindia #viralreels #viralpost #viralvideo" 8 | }, 9 | { 10 | "id": "3088161713358614794_40594752819", 11 | "time": 1682357585, 12 | "imageUrl": "https:\/\/scontent-lhr8-1.cdninstagram.com\/v\/t51.2885-15\/342731423_1240290846597331_4058648294276839052_n.jpg?stp=dst-jpg_e35&_nc_ht=scontent-lhr8-1.cdninstagram.com&_nc_cat=107&_nc_ohc=dqmc_ShukkAAX8y0m1y&edm=AGyKU4gBAAAA&ccb=7-5&ig_cache_key=MzA4ODE2MTcxMzM1ODYxNDc5NA%3D%3D.2-ccb7-5&oh=00_AfAG3wWmyVtvi9uP5Ja5PGjD9IsdUNsUOXpBOPp1wo_CdA&oe=644BFDCD&_nc_sid=4cb768", 13 | "link": "https:\/\/www.instagram.com\/p\/CrbWrdts7EK\/", 14 | "text": "\ud83d\ude0d\u2665\ufe0f ! Hassonii \n\n#photography #photooftheday #love #instagood #instagram #photo #like #nature #picoftheday #follow #photographer #beautiful #fashion #art #bhfyp #likeforlikes #travel #instadaily #me #photoshoot #model #smile #myself #naturephotography #style #happy #instalike #portrait #followme #500px", 15 | "location": "Sanad, Bahrain" 16 | }, 17 | { 18 | "id": "3088161706260880522_50648607956", 19 | "time": 1682357584, 20 | "imageUrl": "https:\/\/scontent-lhr8-2.cdninstagram.com\/v\/t51.2885-15\/342713369_633713828601601_9059031237904346529_n.jpg?stp=dst-jpg_e15&_nc_ht=scontent-lhr8-2.cdninstagram.com&_nc_cat=101&_nc_ohc=4ODp7kkAI5EAX-lju0k&edm=AGyKU4gBAAAA&ccb=7-5&ig_cache_key=MzA4ODE2MTQ1Nzg5OTM1MTE0OQ%3D%3D.2-ccb7-5&oh=00_AfDPAQAJ-qocjIC0ZJOF1VbLQzUuYeYuZ4iUGps_Yv7Qzw&oe=644BEB58&_nc_sid=4cb768", 21 | "link": "https:\/\/www.instagram.com\/p\/CrbWrXGpNyK\/", 22 | "text": "First Lakers game, incredible experience and even better company!\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n#NBA #basketball #summer #california #live #love #life #beautiful #igers", 23 | "carousel": [ 24 | { 25 | "imageUrl": "https:\/\/scontent-lhr8-2.cdninstagram.com\/v\/t51.2885-15\/342713369_633713828601601_9059031237904346529_n.jpg?stp=dst-jpg_e15&_nc_ht=scontent-lhr8-2.cdninstagram.com&_nc_cat=101&_nc_ohc=4ODp7kkAI5EAX-lju0k&edm=AGyKU4gBAAAA&ccb=7-5&ig_cache_key=MzA4ODE2MTQ1Nzg5OTM1MTE0OQ%3D%3D.2-ccb7-5&oh=00_AfDPAQAJ-qocjIC0ZJOF1VbLQzUuYeYuZ4iUGps_Yv7Qzw&oe=644BEB58&_nc_sid=4cb768" 26 | }, 27 | { 28 | "imageUrl": "https:\/\/scontent-lhr8-1.cdninstagram.com\/v\/t51.2885-15\/342715289_893060581795004_3153396065753140033_n.jpg?stp=dst-jpg_e15&_nc_ht=scontent-lhr8-1.cdninstagram.com&_nc_cat=108&_nc_ohc=qqjuiqyqlzwAX8I2nZp&edm=AGyKU4gBAAAA&ccb=7-5&ig_cache_key=MzA4ODE2MTQ1ODI5MzU5MjExMQ%3D%3D.2-ccb7-5&oh=00_AfBCGBUXxpqOD2NKXz8_r4T9jVnrNIfUFtlZgJmc_0ZbPA&oe=644C62C0&_nc_sid=4cb768" 29 | }, 30 | { 31 | "imageUrl": "https:\/\/scontent-lhr8-1.cdninstagram.com\/v\/t51.2885-15\/343072012_907484320540162_1039372692852474228_n.jpg?stp=dst-jpg_e35&_nc_ht=scontent-lhr8-1.cdninstagram.com&_nc_cat=110&_nc_ohc=l5OpObF7R6kAX-3eGjG&edm=AGyKU4gBAAAA&ccb=7-5&ig_cache_key=MzA4ODE2MTcwMTMwMzE5NzA0NA%3D%3D.2-ccb7-5&oh=00_AfD1mHemFXXYLz1Aak0KNTl5niXzoyBLQwfpIeH41LMcRA&oe=644BC45D&_nc_sid=4cb768" 32 | }, 33 | { 34 | "imageUrl": "https:\/\/scontent-lhr8-2.cdninstagram.com\/v\/t51.2885-15\/342726471_2453499761479745_9149297441683190078_n.jpg?stp=dst-jpg_e15&_nc_ht=scontent-lhr8-2.cdninstagram.com&_nc_cat=105&_nc_ohc=0gz-h-I82BEAX-E99Dd&edm=AGyKU4gBAAAA&ccb=7-5&ig_cache_key=MzA4ODE2MTUxNjcxMjA4NDIyMQ%3D%3D.2-ccb7-5&oh=00_AfCVCCebgTyEXTjLwSnfmTe4S8tWeCRompmBemJtimD14g&oe=644C3056&_nc_sid=4cb768" 35 | } 36 | ] 37 | }, 38 | { 39 | "id": "3088161707837730829_59342280877", 40 | "time": 1682357584, 41 | "imageUrl": "https:\/\/scontent-lhr8-1.cdninstagram.com\/v\/t51.2885-15\/343178025_930278174956351_2501709530937346214_n.jpg?stp=dst-jpg_e35&_nc_ht=scontent-lhr8-1.cdninstagram.com&_nc_cat=107&_nc_ohc=2QvmVXNx_m0AX80dE2e&edm=AGyKU4gBAAAA&ccb=7-5&ig_cache_key=MzA4ODE2MTcwNzgzNzczMDgyOQ%3D%3D.2-ccb7-5&oh=00_AfCs264uoeeB6yQnD8QUqrY4V503dHdsMK2RfCScx8uL2g&oe=644AF99A&_nc_sid=4cb768", 42 | "link": "https:\/\/www.instagram.com\/p\/CrbWrYkobAN\/", 43 | "text": "#EARTH#PLANET#NATURE#PLANETEARTH#PEACE#LIFE#LOVE#TRAVEL#2023", 44 | "location": "Planet Earth" 45 | } 46 | ] -------------------------------------------------------------------------------- /test.php: -------------------------------------------------------------------------------- 1 | 'recent', // 30 | 31 |
32 | 33 | ## 📦 Installation from [Composer Repository](https://packagist.org/packages/orsifrancesco/instagram-without-api) 34 | 35 | ```bash 36 | composer require orsifrancesco/instagram-without-api 37 | ``` 38 | 39 | ## 📦 Installation from this Repository 40 | 41 | ```bash 42 | composer install 43 | 44 | # download the file https://github.com/orsifrancesco/instagram-without-api/blob/master/test.php 45 | # add your cookie, user-agent and x-ig-app-id following the next step "How to get Instagram Cookie" 46 | 47 | php test.php 48 | ``` 49 | 50 | ## 🍪 How to get Instagram Cookie 51 | 52 | - Login to Instagram 53 | - Go to your https://instagram/yourUsername 54 | - Open your Browser Console (on Chrome just pressing F12) 55 | 1. Select the "Network" tab 56 | 2. Search and click on "timeline/" file; if it is empty just refresh the page 57 | 3. Select "Headers" bar 58 | 4. Be sure the file is Request Method "POST" (if it is "OPTIONS" search the other "timeline/" file in the list) 59 | 5. Scroll down and select "Request Headers" tab 60 | 6. Copy all the code after the word "cookie: " and paste it on `$cookie` variable 61 | 7. Copy all the code after the word "user-agent: " and paste it on `$userAgent` variable 62 | 8. Copy all the code after the word "x-ig-app-id: " and paste it on `$xIgAppId` variable 63 | ```diff 64 | - don't share your cookie code with anyone!!! it is the same of your credentials 65 | ``` 66 | - That's it, enjoy :) 67 | 68 | ![follow this steps](https://user-images.githubusercontent.com/6490641/181632823-42fb2308-4c3f-421a-848a-58cefcf98915.png "follow this steps") 69 | 70 | ## 💻 Images Base64 71 | Although you can get the URLs of the images, Instagram doesn't give you the possibility to include and showing those images on your projects (they will be automatically blocked from their servers).\ 72 | To solve this problem you will get all the URLs and all the images data in base64.\ 73 | You can easily show the image data on your project with the following snippets of code: 74 | 75 | ```html 76 | 77 | ``` 78 | ```css 79 | .example { background-image: url('data:image/jpg;base64, hereYourBase64String..'); } 80 | ``` 81 | 82 | Check https://orsifrancesco.github.io/instagram-without-api/how-to-show-base64-images.html for Base64 example. 83 | 84 | ## 🛕 Cool Project Example 85 | ![sniffagram](https://user-images.githubusercontent.com/6490641/232155875-ce2ea2ec-eeb5-4bcc-9af7-8c8d82887420.svg "sniffagram") 86 | 87 | ## 🎮 Demo / Example 88 | example on https://github.com/orsifrancesco/instagram-without-api/blob/master/test.php 89 | 90 | ```php 91 | 'recent', //