Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
semstorm-php-sdk/docs/examples/filters/MonitoringUsage.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
74 lines (59 sloc)
1.64 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Example: Using filters in Monitoring endpoints. | |
* | |
* Below are examples with explanation, how to obtain various filtered results. | |
*/ | |
use SemstormApi\Semstorm; | |
use SemstormApi\Monitoring\MonitoringCampaign; | |
Semstorm::init( __ACCESS_TOKEN__ ); | |
//New monitoring campaign object to manage campaigns. | |
$monitoringCampaign = new MonitoringCampaign(); | |
/** | |
* Retrieve campaign data only for keywords with word 'kredyt' in it. | |
*/ | |
// Only keywords which contains word 'kredyt'. | |
$filters = []; | |
$filters[] = [ | |
'field' => 'keyword', | |
'value' => 'kredyt', | |
'operand' => 'contains', | |
]; | |
// Parameters array. | |
$params = []; | |
$params['id'] = __CAMPAIGN_1_ID__; | |
// Put filter into parameters. | |
$params['filters'] = []; | |
$params['filters'] = $filters; | |
// Make API call with filters appended. | |
$response = $monitoringCampaign -> getData( $params ); | |
//See whole response. | |
print_r( $response ); | |
/** | |
* Retrieve keywords on which domain example.com have rose up in SERP, | |
* and only keywords which points to example.com sites with word 'forum' in its url. | |
*/ | |
// Domain filters. | |
$domain = 'example.com'; | |
// Only keywords with posistion change 1 or more (equals to "up") for given domain. | |
$filters = []; | |
$filters[] = [ | |
'field' => 'position_change', | |
'value' => 1, | |
'operand' => 'more', | |
'domain' => $domain, | |
]; | |
// Parameters array. | |
$params = [ ]; | |
$params['domains'] = [ | |
'example.com', | |
'second-example.com' | |
]; | |
// Put set of filters into parameters. | |
$params = []; | |
$params['id'] = __CAMPAIGN_1_ID__; | |
$params['filters'] = $filters; | |
// Make API call with filters appended. | |
$response = $monitoringCampaign -> getData( $params ); | |
//See whole response. | |
print_r( $response ); | |