here is my code :
if (empty($keywords)) {
// Only page URL was specified, so use a UrlSeed.
$requestOptionalArgs['urlSeed'] =
new UrlSeed(['url' => new StringValue(['value' =>
$link_platform_product_page])]);
} elseif (is_null($link_platform_product_page)) {
// Only keywords were specified, so use a KeywordSeed.
$requestOptionalArgs['keywordSeed'] = new KeywordSeed([
'keywords' => array_map(function ($keyword) {
return new StringValue(['value' => $keyword]);
}, $keywords)
]);
} else {
// Both page URL and keywords were specified, so use a KeywordAndUrlSeed.
$requestOptionalArgs['keywordAndUrlSeed'] = new KeywordAndUrlSeed([
'url' => new StringValue(['value' => $link_platform_product_page]),
'keywords' => array_map(function ($keyword) {
return new StringValue(['value' => $keyword]);
}, $keywords)
]);
}
// Create a list of geo target constants based on the resource name of
specified location
// IDs.
$geoTargetConstants = array_map(function ($locationId) {
return new StringValue(
['value' => ResourceNames::forGeoTargetConstant($locationId)]
);
}, $locationIds);
// Generate keyword ideas based on the specified parameters.
$response = $keywordPlanIdeaServiceClient->generateKeywordIdeas(
$customerId,
// Set the language resource using the provided language ID.
new StringValue(['value' => ResourceNames::forLanguageConstant($language)]),
// Add the resource name of each location ID to the request.
$geoTargetConstants,
// Set the network. To restrict to only Google Search, change the parameter
below to
// KeywordPlanNetwork::GOOGLE_SEARCH.
KeywordPlanNetwork::GOOGLE_SEARCH_AND_PARTNERS,
$requestOptionalArgs
);
$keywords = "";
$avgmonthly = "";
$i = 0;
// Iterate over the results and print its detail.
foreach ($response->getResults() as $result) {
if ($result->getKeywordIdeaMetrics()) {
*$competitor = $result->getKeywordIdeaMetrics()->getCompetition();
$avgmonthly =
$result->getKeywordIdeaMetrics()->getAvgMonthlySearches()->getValue();
if ($competitor == 4 && $avgmonthly > 100**) {*
// echo str_word_count($words);
$keywords .= $result->getText()->getValue() . ",";
if ($i++ == $limit) break;
printf(
"Keyword idea text '%s' has %d average monthly searches and
competition as %d.%s",
$result->getText()->getValue(),
is_null($result->getKeywordIdeaMetrics()) ?
0 :
$result->getKeywordIdeaMetrics()->getAvgMonthlySearches()->getValue(),
is_null($result->getKeywordIdeaMetrics()) ?
0 : $result->getKeywordIdeaMetrics()->getCompetition(),
PHP_EOL
);
}
}
}
return $keywords;
how to add $competitor = $result->getKeywordIdeaMetrics()->getCompetition();
$avgmonthly =
$result->getKeywordIdeaMetrics()->getAvgMonthlySearches()->getValue(); before
foreach as paramether so to not generate all the keywords and to filter them
but to generated only keywords i need.
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/8d27dfaa-5e90-43ad-b120-48a6aef12f83%40googlegroups.com.