Skip to content

Commit f813b3f

Browse files
authored
Fixup GMB location ID to parse uint64 IDs (#505)
1 parent 352f259 commit f813b3f

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

google-ads-examples/src/main/java/com/google/ads/googleads/examples/advancedoperations/AddSmartCampaign.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private static class AddSmartCampaignParams extends CodeSampleParams {
115115
"The ID of a Google My Business (GMB) location. This is required if a business name is"
116116
+ " not provided. It can be retrieved using the GMB API, for details see:"
117117
+ " https://developers.google.com/my-business/reference/rest/v4/accounts.locations")
118-
private Long locationId;
118+
private String locationId;
119119

120120
@Parameter(
121121
names = ArgumentNames.BUSINESS_NAME,
@@ -139,7 +139,7 @@ public static void main(String[] args) throws IOException {
139139
params.freeFormKeywordText = null;
140140

141141
// Must specify one of location ID or business name.
142-
params.locationId = Long.valueOf("INSERT_BUSINESS_LOCATION_ID_HERE");
142+
params.locationId = "INSERT_BUSINESS_LOCATION_ID_HERE";
143143
params.businessName = "INSERT_BUSINESS_NAME";
144144
}
145145

@@ -185,17 +185,24 @@ private void runExample(
185185
long customerId,
186186
String keyword,
187187
String freeFormKeywordText,
188-
Long locationId,
188+
String locationId,
189189
String businessName) {
190190
if (locationId == null && businessName == null) {
191191
throw new RuntimeException("Must provider either --locationId or --businessName");
192192
}
193+
194+
// [START add_smart_campaign_14]
195+
// Converts the location ID to unsigned long (potentially contains IDs with the most significant
196+
// bit set).
197+
long locationIdParsed = Long.parseUnsignedLong(locationId);
198+
// [END add_smart_campaign_14]
199+
193200
// [START add_smart_campaign_12]
194201
// Gets the SmartCampaignSuggestionInfo object which acts as the basis for many of the
195202
// entities necessary to create a Smart campaign. It will be reused a number of times to
196203
// retrieve suggestions for keyword themes, budget amount, ad creatives, and campaign criteria.
197204
SmartCampaignSuggestionInfo suggestionInfo =
198-
getSmartCampaignSuggestionInfo(googleAdsClient, locationId, businessName);
205+
getSmartCampaignSuggestionInfo(googleAdsClient, locationIdParsed, businessName);
199206

200207
// Generates a list of keyword themes using the SuggestKeywordThemes method on the
201208
// SmartCampaignSuggestService. It is strongly recommended that you use this strategy for
@@ -238,7 +245,7 @@ private void runExample(
238245
Arrays.asList(
239246
createCampaignBudgetOperation(customerId, suggestedDailyBudgetMicros),
240247
createSmartCampaignOperation(customerId),
241-
createSmartCampaignSettingOperation(customerId, locationId, businessName),
248+
createSmartCampaignSettingOperation(customerId, locationIdParsed, businessName),
242249
createAdGroupOperation(customerId),
243250
createAdGroupAdOperation(customerId, adSuggestions)));
244251
operations.addAll(

google-ads-examples/src/main/resources/log4j2.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ information about slf4j.
3131
</Appenders>
3232
<Loggers>
3333
<Logger name="com.google.ads.googleads.lib.request.summary" level="info"/>
34-
<Logger name="com.google.ads.googleads.lib.request.detail" level="info"/>
34+
<Logger name="com.google.ads.googleads.lib.request.detail" level="all"/>
3535
<Root level="off">
3636
<AppenderRef ref="CONSOLE"/>
3737
</Root>

0 commit comments

Comments
 (0)