get_name error on OfflineConversionFeed (Perl)

24 views
Skip to first unread message

d...@adservice.com

unread,
Jun 20, 2014, 5:15:40 AM6/20/14
to adwor...@googlegroups.com
I am trying to use the UploadConversion API and it seems to be working, some of the conversions are getting imported, but when my script should display the results i get the following error:
Can't locate object method "get_value" via package "Google::Ads::AdWords::v201402::OfflineConversionFeed".
Valid methods are:
 at /usr/local/share/perl5/SOAP/WSDL/XSD/Typelib/ComplexType.pm line 68.
SOAP::WSDL::XSD::Typelib::ComplexType::AUTOMETHOD(Google::Ads::AdWords::v201402::OfflineConversionFeed=SCALAR(0x4332530), 70460720) called at /usr/local/share/perl5/Class/Std.pm line 545
Class::Std::AUTOLOAD(Google::Ads::AdWords::v201402::OfflineConversionFeed=SCALAR(0x4332530)) called at ./importgclids.pl line 78

I am using a modified version of the upload_offline_conversions.pl example:
    my $clientSettings = &const::GoogleAPIClient();
    my $client = Google::Ads::AdWords::Client->new({version => "v201402"});
    $client->set_developer_token($clientSettings->{developer_token});
    $client->get_oauth_2_handler()->set_client_id($clientSettings->{client_id});
    $client->get_oauth_2_handler()->set_client_secret($clientSettings->{client_secret});
    $client->get_oauth_2_handler()->set_access_token($GoogleAccountConnection->{access_token});
    $client->get_oauth_2_handler()->set_refresh_token($GoogleAccountConnection->{refresh_token});
    
    my @search;
    push(@search, "a1.exported=0");
    push(@search, "a2.agent_id='$agent_id'");
    push(@search, "a2.status='approve'");
    push(@search, "DATE_FORMAT(a2.stamp,'%y%m%d')<=DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 DAY),'%y%m%d')");
    my $search = join(" AND ", @search);
    
    my @orders;
    my $orders = &db::select_rows("SELECT a1.id, a1.gclid, DATE_FORMAT(a2.stamp, '%Y%m%d %H%i%s') as stamp, (a2.pay_for_lead+a2.pay_for_sale) as value, conversionName FROM gclid_order_log a1 JOIN lead_log a2 ON a1.lead_log_id=a2.record_id WHERE $search");
    while (my $order = $orders->fetchrow_hashref()) {
        $order->{conversionName} = $agent->{conversionName} if (!$order->{conversionName});
        $order->{action} = "ADD";
        
        if ($order->{conversionName}) {
            print "$order->{action}, $order->{gclid}, $order->{conversionName}, $order->{value}, $order->{stamp}\n";
            
            my $feed = Google::Ads::AdWords::v201402::OfflineConversionFeed->new({
                conversionName => $order->{conversionName},
                conversionTime => $order->{stamp} ." Europe/Copenhagen",
                conversionValue => $order->{value},
                googleClickId => $order->{gclid}
            });
            
            my $offline_conversion_operation = Google::Ads::AdWords::v201402::OfflineConversionFeedOperation->new({
                operator => "ADD",
                operand => $feed
            });
            push(@orders, $offline_conversion_operation);
        }
    }
    
    if (scalar@orders>0) {
        # Add the upload conversion.
        my $feed_result = $client->OfflineConversionFeedService()->mutate({
            operations => \@orders
        });
        
        # Display results.
        if ($feed_result->get_value()) {
            foreach my $oc_feed (@{$feed_result->get_value()}) {                
                printf "Uploaded offline conversion value of \"%s\" for Google Click ID \"%d\" was created.\n", $oc_feed->get_name(), $oc_feed->get_id();
            }
        } else {
            print "No offline conversion were added.\n";
        }
    } else {
        print "No conversions to add.";
    }

What am i doing wrong here?

Josh Radcliff (AdWords API Team)

unread,
Jun 23, 2014, 2:16:56 PM6/23/14
to adwor...@googlegroups.com
Hi,

Your post highlighted a few issues with that example. I opened github issue #4 for this and I'm working on a new version of the library to fix it.


In the meantime, you can avoid this error if you modify the printf statement after OfflineConversionFeedService.mutate as follows:

1. Replace get_id with get_googleClickId
2. Replace get_name with get_conversionName and get_id with get_googleClickId
3. Change "ID \"%d\" was created.\n" with "ID \"%s\" was created.\n", since click IDs are strings, not numbers

Thanks,
Josh, AdWords API Team

d...@adservice.com

unread,
Jun 24, 2014, 4:19:02 AM6/24/14
to adwor...@googlegroups.com
Yes, now its working, thanks a lot!

 - Daniel
Reply all
Reply to author
Forward
0 new messages