PHP code example of misarai / misarseo-php
1. Go to this page and download the library: Download misarai/misarseo-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/ */
misarai / misarseo-php example snippets
use MisarSEO\Client;
$seo = new Client(getenv('MISARSEO_API_KEY'));
new Client(
'mseo_…',
baseUrl: 'https://api.misar.io/seo', // default
timeout: 30.0,
maxRetries: 2,
);
$projectId = $seo->projects->list()['projects'][0]['id'];
$ideas = $seo->keywords->research(['projectId' => $projectId, 'keywords' => ['seo tools']]);
$job = $seo->crawl->start(['projectId' => $projectId, 'startUrl' => 'https://example.com']);
foreach ($seo->crawl->streamEvents($job['jobId'], $projectId) as $frame) {
echo $frame->event, ' ', json_encode($frame->data), PHP_EOL; // progress … then complete or error
}
$profile = $seo->backlinks->overview($projectId, 'example.com');
try {
$seo->projects->get('nope');
} catch (MisarSEO\MisarSeoException $e) {
echo $e->status, ' ', $e->getErrorCode(); // 404 NOT_FOUND
}
try {
$seo->keywords->research(['projectId' => $projectId, 'keywords' => ['seo']]);
} catch (MisarSEO\PlanLimitException $e) {
echo $e->offer['headline'], ' ', $e->upgradeUrl;
}
foreach (MisarSEO\Pagination::offsetRows(
fn (int $page) => $seo->backlinks->anchors($projectId, 'example.com', ['page' => $page])
) as $anchor) {
print_r($anchor);
}
bash
composer json
{ "error": "...", "code": "plan_limit_exceeded", "upgrade": { "reason", "feature", "headline", "plans": [...], "urls": { "pricing" }, "cta" } }