PHP code example of skmachine / instagram-php-scraper
1. Go to this page and download the library: Download skmachine/instagram-php-scraper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
skmachine / instagram-php-scraper example snippets
nstagramScraper\Client;
$client = new Client([
// get your key on https://rapidapi.com/neotank/api/instagram130
'rapidapi_key' => 'YOUR-RAPIDAPI-KEY'
]
);
$response = $client->getAccountInfo([
'username' => 'adele'
]);
echo '<h2>Account info for adele:</h2><pre>';
print_r($response);
echo '</pre>';
/**
* get user posts (without reels)
*/
$response = $client->getAccountMedias([
'userid' => '13460080',
// 'first' => 80,
// 'after' =>
// get 'after' cursor from page_info.end_cursor if page_info.has_next_page == 1
]);
use InstagramScraper\MediaProxy;
// use allowedReferersRegex to restrict other websites hotlinking images from your website
$proxy = new MediaProxy(['allowedReferersRegex' => "/(yourwebsite\.com|anotherallowedwebsite\.com)$/"]);
$proxy->handle($_GET, $_SERVER);
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.