1. Go to this page and download the library: Download aporat/scrapecreators-php 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/ */
aporat / scrapecreators-php example snippets
use Aporat\ScrapeCreators\Client;
$client = new Client($apiKey, [
'cache_max_age' => '1d', // optional: accept scrapes up to a day old for 0 credits
'timeout' => 20, // seconds, the default
]);
$profile = $client->instagram()->profile('nasa');
$profile->get('data.user.follower_count');
$profile->creditsCharged(); // 1 for a live scrape, 0 from the cache
$profile->isCached();
$response = $client->instagram()->profile('nasa');
$response->data(); // the `data` member, or the whole envelope when there is none
$response->get('data.user.biography'); // dot path, with an optional default
$response['data']['user']; // array access to the envelope
$response->toArray();
$response->creditsCharged(); // int|null
$response->creditsRemaining(); // int|null
$response->isCached(); // served from Scrape Creators' cache (0 credits)
$response->cachedAt(); // DateTimeImmutable|null
$response->raw(); // the PSR-7 response
$client = new Client($apiKey, ['cache_max_age' => '1d']);
$client->instagram()->profile('nasa'); // cache_max_age=1d
$client->instagram()->profile('nasa', cacheMaxAge: '7d'); // cache_max_age=7d
$client->instagram()->profile('nasa', cacheMaxAge: Client::LIVE); // no cache_max_age: a live scrape
use Aporat\ScrapeCreators\Exceptions\InsufficientCreditsException;
use Aporat\ScrapeCreators\Exceptions\NotFoundException;
use Aporat\ScrapeCreators\Exceptions\RestrictedException;
use Aporat\ScrapeCreators\Exceptions\ScrapeCreatorsException;
use Aporat\ScrapeCreators\Exceptions\UnavailableException;
try {
$profile = $client->instagram()->profile($handle);
} catch (NotFoundException) {
// No such account. Safe to cache as a miss.
} catch (RestrictedException $e) {
// The account exists but the network will not show it: $e->isAgeRestricted(), $e->isPrivate().
// Do not reject the handle and do not cache it as missing; restrictions lift.
} catch (UnavailableException $e) {
// Their outage, or a timeout. Says nothing about the account; retry later.
} catch (InsufficientCreditsException) {
// Top up.
} catch (ScrapeCreatorsException $e) {
$e->getStatusCode(); // int|null
$e->getApiMessage(); // the envelope's `message`, when there was one
$e->getBody(); // the decoded envelope
$e->getResponse(); // the PSR-7 response
}
public function __construct(private readonly \Aporat\ScrapeCreators\Client $scrapeCreators) {}