PHP code example of silktide / semrush-api

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

    

silktide / semrush-api example snippets


    $client = \Silktide\SemRushApi\ClientFactory::create("[YOUR SEMRUSH API KEY]");

    $cache = new Psr16CompliantCache();
    $client->setCache($cache)

    $result = $client->getDomainRanks('silktide.com');

    $result = $client->getDomainRank(
        'silktide.com',
        [
            'database' => \Silktide\SemRushApi\Data\Database::DATABASE_GOOGLE_US
        ]
    );

    $result = $client->getDomainRankHistory(
        'silktide.com',
        [
            'database' => \Silktide\SemRushApi\Data\Database::DATABASE_GOOGLE_US
        ]
    );

    $result = $client->getDomainOrganic(
        'silktide.com',
        [
            'database' => \Silktide\SemRushApi\Data\Database::DATABASE_GOOGLE_US
        ]
    );

    $result = $client->getDomainAdwords(
        'silktide.com',
        [
            'database' => \Silktide\SemRushApi\Data\Database::DATABASE_GOOGLE_US
        ]
    );

    $result = $client->getDomainAdwordsUnique(
        'silktide.com',
        [
            'database' => \Silktide\SemRushApi\Data\Database::DATABASE_GOOGLE_US
        ]
    );

    $result = $client->getDomainRanks('silktide.com', [
        'export_columns' => [
            \Silktide\SemRushApi\Data\Column::COLUMN_OVERVIEW_ADWORDS_BUDGET,
            \Silktide\SemRushApi\Data\Column::COLUMN_OVERVIEW_ADWORDS_KEYWORDS,
            \Silktide\SemRushApi\Data\Column::COLUMN_OVERVIEW_ADWORDS_TRAFFIC
         ]
    ]);

    foreach ($result as $row) {
        $budget = $row->getValue(\Silktide\SemRushApi\Data\Column::COLUMN_OVERVIEW_ADWORDS_BUDGET);
        echo "\nThe AdWords spend of this site in the last month was an estimated ${$budget}";
    }