Hello Peter,
Can you share your piece of code for the keywords "trump, biden" that is
working nicely on your side?
Also, I do not have permission for the option for "Reply privately to
author".
*Here is my request file:-*
<?php
require __DIR__ . '/../../vendor/autoload.php';
use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSession;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201809\cm\Language;
use Google\AdsApi\AdWords\v201809\cm\NetworkSetting;
use Google\AdsApi\AdWords\v201809\cm\Paging;
use Google\AdsApi\AdWords\v201809\o\AttributeType;
use Google\AdsApi\AdWords\v201809\o\IdeaType;
use Google\AdsApi\AdWords\v201809\o\LanguageSearchParameter;
use Google\AdsApi\AdWords\v201809\o\NetworkSearchParameter;
use Google\AdsApi\AdWords\v201809\o\RelatedToQuerySearchParameter;
use Google\AdsApi\AdWords\v201809\o\RequestType;
use Google\AdsApi\AdWords\v201809\o\SeedAdGroupIdSearchParameter;
use Google\AdsApi\AdWords\v201809\o\TargetingIdeaSelector;
use Google\AdsApi\AdWords\v201809\o\TargetingIdeaService;
use Google\AdsApi\Common\OAuth2TokenBuilder;
use Google\AdsApi\Common\Util\MapEntries;
class GetKeywordIdeas
{
// If you do not want to use an existing ad group to seed your request, you
// can set this to null.
const AD_GROUP_ID = null;
const PAGE_LIMIT = 500;
public static function runExample(
AdWordsServices $adWordsServices,
AdWordsSession $session,
$adGroupId
) {
$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::AVERAGE_CPC,
AttributeType::COMPETITION,
AttributeType::CATEGORY_PRODUCTS_AND_SERVICES
]
);
$paging = new Paging();
$paging->setStartIndex(0);
$paging->setNumberResults(10);
$selector->setPaging($paging);
$searchParameters = [];
// Create related to query search parameter.
$relatedToQuerySearchParameter = new RelatedToQuerySearchParameter();
*$relatedToQuerySearchParameter->setQueries(*
* [*
*'Trump', 'biden'*
* ]*
* );*
$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;
// Optional: Use an existing ad group to generate ideas.
if (!empty($adGroupId)) {
$seedAdGroupIdSearchParameter = new SeedAdGroupIdSearchParameter();
$seedAdGroupIdSearchParameter->setAdGroupId($adGroupId);
$searchParameters[] = $seedAdGroupIdSearchParameter;
}
$selector->setSearchParameters($searchParameters);
$selector->setPaging(new Paging(0, self::PAGE_LIMIT));
// Get keyword ideas.
$page = $targetingIdeaService->get($selector);
// Print out some information for each targeting idea.
$entries = $page->getEntries();
if ($entries !== null) {
foreach ($entries 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;
$averageCpc = $data[AttributeType::AVERAGE_CPC]->getValue();
$competition = $data[AttributeType::COMPETITION]->getValue();
$categoryIds =
($data[AttributeType::CATEGORY_PRODUCTS_AND_SERVICES]->getValue() === null)
? $categoryIds = ''
: implode(
', ',
$data[AttributeType::CATEGORY_PRODUCTS_AND_SERVICES]->getValue()
);
$aFinalArray = [];
$aSubArray = [];
$arr[] = array('keyword' => $keyword, 'cpc' => $averageCpc, 'competition'
=> $competition, 'search_volumenew' => $searchVolume);
}
$aFinalArray = $arr;
echo "<pre>"; print_r($aFinalArray); die;
}
if (empty($entries)) {
print "No related keywords were found.\n";
}
}
public static function main()
{
*$adsConfigPath = __DIR__ . '/../adsapi_php.ini'; // My config file*
$oAuth2Credential = (new
OAuth2TokenBuilder())->fromFile($adsConfigPath)->build();
$session = (new
AdWordsSessionBuilder())->fromFile($adsConfigPath)->withOAuth2Credential($oAuth2Credential)->build();
$aDataInfo = self::runExample(new AdWordsServices(), $session,
self::AD_GROUP_ID);
}
}
GetKeywordIdeas::main();
On Tuesday, 24 November 2020 at 08:00:07 UTC+5:30 adsapiforumadvisor wrote:
> Hi Neetu,
>
> So our team can investigate this further, could you provide your customer
> ID and the complete request
> <https://developers.google.com/adwords/api/docs/guides/call-structure#request>
>
> and response
> <https://developers.google.com/adwords/api/docs/guides/call-structure#response>
>
> logs that were generated?
>
> In addition, could you confirm whether the same input generated results in
> the Keyword Planner <https://ads.google.com/home/tools/keyword-planner/>?
> If yes, could you also send a screenshot?
>
> You may send the requested details using the *Reply privately to author*
> option.
>
> Best regards,
>
> [image: Google Logo]
> Peter Laurence Napa Oliquino
> Google Ads API Team
>
>
> ref:_00D1U1174p._5004Q27v7E8:ref
>
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/18770232-2d9a-4522-9c7c-74c04b9fad69n%40googlegroups.com.