PHP code example of hakone / indexnow

1. Go to this page and download the library: Download hakone/indexnow 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/ */

    

hakone / indexnow example snippets


use Hakone\IndexNow\IndexNow;
use Http\Discovery\Psr18ClientDiscovery;

$client = new IndexNow(Psr18ClientDiscovery::find());

$key = '...';

// Submitting One URL
$client->submitUrl('www.example.com', $key, 'http://www.example.com/product.html');

// Submitting set of URLs
$client->submitList('www.example.com', $key, [
    'https://www.example.com/url1',
    'https://www.example.com/folder/url2',
    'https://www.example.com/url3',
]);