1. Go to this page and download the library: Download scrapingisnotacrime/sdk 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/ */
scrapingisnotacrime / sdk example snippets
use ScrapingIsNotACrime\Client;
use ScrapingIsNotACrime\Exception\NotFoundException;
$client = new Client(apiKey: 'sinac_...');
try {
$profile = $client->instagram->profile('nasa');
echo $profile->username, ' ', $profile->followers, PHP_EOL;
} catch (NotFoundException) {
echo 'no such profile', PHP_EOL;
}
use GuzzleHttp\Client;
use ScrapingIsNotACrime\Client as ScrapingIsNotACrimeClient;
$client = new ScrapingIsNotACrimeClient(
apiKey: 'sinac_...',
httpClient: new Client([
'timeout' => 30,
'allow_redirects' => false,
// 'proxy' => 'http://localhost:8080',
]),
);
use ScrapingIsNotACrime\Client as ScrapingIsNotACrimeClient;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpClient\Psr18Client;
$client = new ScrapingIsNotACrimeClient(
apiKey: 'sinac_...',
httpClient: new Psr18Client(HttpClient::create([
'timeout' => 30,
'max_duration' => 30,
'max_redirects' => 0,
// 'proxy' => 'http://localhost:8080',
])),
);
final class Page implements \IteratorAggregate
{
public readonly array $items; // this page's items, already decoded
public readonly bool $hasMore;
public readonly ?string $nextCursor; // cursor endpoints; null when there is none
public readonly ?int $nextPage; // page-number endpoints; null when there is none
public readonly object $data; // this page's typed page object (e.g. GithubUserPage), with fields like ->total
public function next(): ?self; // fetches the following page; null when there is none
public function getIterator(): \Generator; // yields items across pages, lazily
}