PHP code example of serpstat / sdk

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

    

serpstat / sdk example snippets



onfigure your application
$config = [
    'token' => '19666fc1ae1724da1d5ea2f3a99d5f5a',
];

$domain = 'example.com';
$keywords = 'keywords';
$url = 'http://example.com/page1/';

// init client with your serpstat api token
$apiClient = new \Serpstat\Sdk\Core\ApiGuzzleHttpClient($config['token']);

// create instance of any api method class
// e.g. DomainKeywordsMethod
// list of methods classes in folder src\Methods
$apiMethod = new \Serpstat\Sdk\Methods\DomainKeywordsMethod(
    $keywords, 
    \Serpstat\Sdk\Interfaces\IApiClient::SE_GOOGLE_RU
);

try {
    // try call api method
    $response = $apiClient->call($apiMethod);
} catch (\Exception $e) {
    // catch api error 
    $response = $e->getMessage();
}