Hello, I'm creating script to gather search volume of keyword list, so I
was getting to big search volume
so I tried this test code:
/**
* @param AdWordsServices $adWordsServices
* @param AdWordsSession $session
*/
public static function runExample(AdWordsServices $adWordsServices,
AdWordsSession $session)
{
$targetingIdeaService =
$adWordsServices->get($session, TargetingIdeaService::class);
// Create selector.
$selector = new TargetingIdeaSelector();
$selector->setRequestType(RequestType::STATS);
$selector->setIdeaType(IdeaType::KEYWORD);
$selector->setRequestedAttributeTypes([
AttributeType::KEYWORD_TEXT,
AttributeType::SEARCH_VOLUME,
AttributeType::CATEGORY_PRODUCTS_AND_SERVICES
]);
$searchParameters = [];
// Create seed keyword.
$keyword = 'aasdasdasdasdasdasdasdasdasd';
// Create related to query search parameter.
$relatedToQuerySearchParameter = new RelatedToQuerySearchParameter();
$relatedToQuerySearchParameter->setQueries([$keyword]);
$searchParameters[] = $relatedToQuerySearchParameter;
// Create language search parameter (optional).
// The ID can be found in the documentation:
// https://developers.google.com/adwords/api/docs/appendix/languagecodes
$languageParameter = new LanguageSearchParameter();
$english = new Language();
$english->setId(1000);
$languageParameter->setLanguages([$english]);
$searchParameters[] = $languageParameter;
// Create network search parameter (optional).
$networkSetting = new NetworkSetting();
$networkSetting->setTargetGoogleSearch(true);
$networkSetting->setTargetSearchNetwork(false);
$networkSetting->setTargetContentNetwork(false);
$networkSetting->setTargetPartnerSearchNetwork(false);
$networkSearchParameter = new NetworkSearchParameter();
$networkSearchParameter->setNetworkSetting($networkSetting);
$searchParameters[] = $networkSearchParameter;
$selector->setSearchParameters($searchParameters);
$selector->setPaging(new Paging(0, 50));
$totalNumEntries = 0;
do {
// Retrieve targeting ideas one page at a time, continuing to request
// pages until all of them have been retrieved.
$page = $targetingIdeaService->get($selector);
// Print out some information for each targeting idea.
if ($page->getEntries() !== null) {
$totalNumEntries = $page->getTotalNumEntries();
foreach ($page->getEntries() as $targetingIdea) {
$data =
MapEntries::toAssociativeArray($targetingIdea->getData());
$keyword = $data[AttributeType::KEYWORD_TEXT]->getValue();
$searchVolume =
($data[AttributeType::SEARCH_VOLUME]->getValue() !== null)
? $data[AttributeType::SEARCH_VOLUME]->getValue() : 0;
$categoryIds =
($data[AttributeType::CATEGORY_PRODUCTS_AND_SERVICES]->getValue()
=== null)
? $categoryIds = '' : implode(', ', $data[
AttributeType::CATEGORY_PRODUCTS_AND_SERVICES]->getValue());
printf(
"Keyword idea with text '%s', category IDs (%d) and average
"
. "monthly search volume %d was found.\n",
$keyword,
$categoryIds,
$searchVolume
);
}
}
$selector->getPaging()->setStartIndex(
$selector->getPaging()->getStartIndex() + 50);
} while ($selector->getPaging()->getStartIndex() < $totalNumEntries);
printf("Number of results found: %d\n", $totalNumEntries);
}
and the output is like this:
<https://lh3.googleusercontent.com/-qi_9dV3Ekos/WSsZkP1fbfI/AAAAAAAAADQ/hZZ0k9xoTNMAQwK8-BbTS42W1VWDphdcQCLcB/s1600/Screen%2BShot%2B2017-05-28%2Bat%2B8.09.16%2BPM.png>
so if anyone can tell me what have I done wrong, cause the big results are
always showing in response?
Thanks
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords 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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/d3f40c08-bdd1-4744-b0f2-4dd6f6baa382%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.