Hi,
It looks to me like you're using an incorrect XPath expression to
get to your results. "//body" i.e. I guess using "//moreSpecific"
should help.
I've also had a try at this using Google::Adwords, but on the
sandbox.
my $seed_keyword1 = Google::Adwords::SeedKeyword->new;
$seed_keyword1->negative(0);
$seed_keyword1->text('trusted places');
$seed_keyword1->type('Broad');
my $keyword_variations = $service->getKeywordVariations(
{
seedKeywords => [ $seed_keyword1, ],
useSynonyms => 1,
languages => [ 'en', ],
countries => [ 'US', ],
}
);
for ( @{ $keyword_variations->moreSpecific } ) {
print "Text: " . $_->text . "\n";
print "advertiserCompetitionScale: "
. $_->advertiserCompetitionScale . "\n";
}
Hope this helps.
--
Rohan
discodan wrote:
> Hi all,
>
> Would really appreciate your help. This is probably more of a Perl /
> SOAP than adwords API question, but I've spent hours trawling the
> internet for an answer to this and cannot find it, so I'm hoping you
> can help :). I'm relatively new to Perl and SOAP, and I'm trying to
> implement a connection to the Google Adwords API using SOAP::Lite. I
> have it almost working but however I try and get a return value from
> SOAP::SOM (e.g. using valueof or result) I only seem to get the last
> element. Even calling valueof("//Body") just gives me one element. I
> have tried debugging the code and using Dumper, but the SOAP::Lite
> code is quite unreadable (at least to me :)
> and I can't work out whats going on. I've tried implementing this
> directly both using SOAP::Lite and via Google::Adwords, and they both
> have the same behaviour.
>
> This what I get from valueof("//Body):
>
> $VAR1 = {
> 'getKeywordVariationsResponse' => {
>
> 'getKeywordVariationsReturn' => {
>
> 'moreSpecific' => {
>
> 'searchVolumeScale' => '2',
>
> 'language' => '',
>
> 'text' => 'trusted places 1',
>
> 'advertiserCompetitionScale' => '3'
>
> }
>
> }
> }
> };
>
> But I know there is more than one KeywordVariation from using Dumper
> on the SOAP::SOM object.
>
> This is the code I am using, its basically the example provided by
> Google:
>
> use strict;
> use warnings;
> use English '-no_match_vars';
> use SOAP::Lite;
> use Data::Dumper;
> binmode(STDOUT, ':utf8');
>
> # Provide AdWords login information.
> my $email = '';
> my $password = '';
> my $client_email = '[email protected]';
> my $useragent = 'QYPE: AdWords API Perl Sample Code';
> my $developer_token = '[email protected]++usd';
> my $application_token = 'INSERT_APPLICATION_TOKEN_HERE';
>
> # Set up service connection with autotyping disabled and fault handler
> # registered. To send requests to production environment, replace
> "sandbox" with
> # "adwords". To view XML request/response, uncomment
> # "SOAP::Lite->import(+trace => 'debug');".
> my $url =
> sprintf('https://%s.google.com/api/adwords/v12/KeywordToolService',
> 'sandbox');
>
> my $wsdl = $url . '?wsdl';
>
> my $service =
> SOAP::Lite->service($wsdl)->autotype(0)->readable(1)->proxy($url);
>
> $service->on_fault(sub {
> my $response = $ARG[1];
> die('The following SOAP fault occurred:', "\n",
> ' faultcode: ', $response->faultcode(), "\n",
> ' faultstring: ', $response->faultstring(),
> "\n")
> });
> SOAP::Lite->import(+trace => 'debug');
>
> # Define SOAP headers.
> my @headers = (
> SOAP::Header->name('email' => $email),
> SOAP::Header->name('password' => $password),
> SOAP::Header->name('clientEmail' => $client_email),
> SOAP::Header->name('useragent' => $useragent),
> SOAP::Header->name('developerToken' => $developer_token),
> SOAP::Header->name('applicationToken' => $application_token)
> );
>
> # Create seed keyword structure.
> my $seed_keyword = {
> 'negative' => 'false',
> 'text' => 'trusted places',
> 'type' => 'Broad',
> };
>
> my $seed_keywords = SOAP::Data->name('seed_keywords' =>
> [$seed_keyword]);
> my $use_synonyms = SOAP::Data->name('useSynonyms' => 'true');
> my $languages = SOAP::Data->name('languages' => ['en']);
> my $countries = SOAP::Data->name('countries' => ['US']);
>
> # Get keyword variations.
> my $variation_lists = $service->call('getKeywordVariations' =>
> $seed_keywords,
> $use_synonyms, $languages, $countries, @headers);
>
> print Dumper($variation_lists);
>
> my @data = $variation_lists->valueof("//Body");
>
> foreach my $data_word (@data){
> print Dumper($data_word);
> }
>
> If anyone knows where I am going wrong I'd be most grateful!
>
> Thanks for your help.
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---