Skip to content

PHP library for sumbitting website URLs using IndexNow to search engines.

License

Notifications You must be signed in to change notification settings

nemorize/php-indexnow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-indexnow

php-indexnow is a PHP library for IndexNow API.

Example usage

composer require nemorize/indexnow
$indexnow = new \Nemorize\Indexnow\Indexnow();
$indexnow->setKey('fc1e3ad82010475381daf9846e627fdd');
$indexnow->submit('https://example.com/url-changed');
$indexnow->submit([
    'https://example.com/url-changed',
    'https://example.com/url-changed-2'
]);

Specification

setHost

Indexnow::setHost (string $host): void;

You can change the hostname of the API. If you don't set the hostname, the default host is api.indexnow.org.

getHost

Indexnow::getHost (): string;

Returns the hostname of the API.

setKey

Indexnow::setKey (string $key): void;

You can change the key of the API.

getKey

Indexnow::getKey (): string;

Returns the key of the API.

setKeyLocation

Indexnow::setKeyLocation (?string $keyLocation): void;

You can change the key location of the API. If you want to unset the key location, you can set null.

getKeyLocation

Indexnow::getKeyLocation (): ?string;

Returns the key location of the API.

submit

Indexnow::submit (string|array $url, array $guzzleOptions = null): void;

You can submit a URL to the API. If you use $url as an array, it will submit multiple URLs using JSON request. $guzzleOptions is an array of options for Guzzle.

Exceptions

submit method throws exceptions if some errors occur. If the API throws well-known non-20x response codes, it will throw the following exceptions that extend IndexnowException. Any other errors will throw GuzzleException.

  • BadRequestException
  • ForbiddenException
  • TooManyRequestsException
  • UnprocessableEntityException

License

MIT License

About

PHP library for sumbitting website URLs using IndexNow to search engines.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages