1. Go to this page and download the library: Download inwebo/save-page-now-2 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/ */
inwebo / save-page-now-2 example snippets
use Inwebo\SavePageNow2\Auth\S3Credentials;
use Inwebo\SavePageNow2\Capture\CaptureOptionsBuilder;
use Inwebo\SavePageNow2\Response\JobStatus;
use Inwebo\SavePageNow2\SavePageNow2Client;
use Symfony\Component\HttpClient\HttpClient;
$client = new SavePageNow2Client(
HttpClient::create(),
new S3Credentials('my-access-key', 'my-secret'),
);
// 1. Submit a URL
$options = (new CaptureOptionsBuilder())
->withSkipFirstArchive() // Faster
->withJsBehaviorTimeout(0) // No JS execution
->build();
$job = $client->capture('https://example.com/', $options);
echo "Job started: {$job->jobId}\n";
// 2. Poll until completion
do {
sleep(5);
$status = $client->getStatus($job->jobId);
} while ($status->getStatus() === JobStatus::Pending);
// 3. Result
if ($status->getStatus() === JobStatus::Success) {
echo "✅ Archived: {$status->getWaybackUrl()}\n";
} else {
echo "❌ Error: {$status->getMessage()} ({$status->getStatusExt()})\n";
}
use Inwebo\SavePageNow2\Exception\AuthenticationException;
use Inwebo\SavePageNow2\Exception\UserSessionLimitException;
use Inwebo\SavePageNow2\Exception\NetworkException;
use Inwebo\SavePageNow2\Exception\ApiException;
try {
$job = $client->capture('https://example.com/');
} catch (AuthenticationException $e) {
// Invalid or expired S3 keys
} catch (UserSessionLimitException $e) {
// 12 simultaneous captures reached (auth) / 6 (anonymous)
} catch (NetworkException $e) {
// Transport issue (timeout, DNS...)
} catch (ApiException $e) {
// Unexpected API response
}