Retrieve loner sitelinks using extension setting service

59 views
Skip to first unread message

mm

unread,
Jun 26, 2015, 7:03:18 PM6/26/15
to adwor...@googlegroups.com
Hey guys -
I was looking at moving all of my current feed-based sitelink management code to the CampaignExtensionSettingService. Right now, with Feed services I can retrieve all sitelinks for an account regardless of whether they have been associated with a Campaign or AdGroup. When using these new(ish) Extension services, is there a way to achieve the same end? I tried a retrieval with the CampaignExtensionSettingService where I only specified the extension type in the selector, but none of the sitelinks were returned (I assume because they weren't associated with a campaign).

Thanks for your help!
mm

Juergen Henning

unread,
Jun 29, 2015, 10:21:30 AM6/29/15
to adwor...@googlegroups.com
Hi Magaret,

I don't know how to read all existing sitelinks with the CampaignExtensionSettingService. But I want to know, how I can filter all sitelinks with the FeedItemService. Do you have a code example?

Thanks in advance and - sorry for the offtopic question...
Juergen

mm

unread,
Jun 29, 2015, 12:31:57 PM6/29/15
to adwor...@googlegroups.com
Hey Juergen -
FWIW, after digging around some more, it looks like I might need to use the CustomerExtensionSettingService to read all the sitelinks for an account. Haven't had time to confirm yet. 

Perhaps I misspoke slightly when I said I was reading the sitelinks for a feed. I am looking at the mappings, and if a feed has a valid Sitelink mapping, then I am reading all the feeditems for that feed via FeedItemService.
I am sure there are already some code samples out there for that, but in case it is useful for you, my code reading the feeditems looks like this:

FeedItemServiceInterface feedService = getFeedItemService(acctId);
Selector selector = new Selector();
selector.setFields(new String[] { "FeedId", "FeedItemId", "StartTime", "EndTime", "AttributeValues", "PolicyData", "DevicePreference", "Status", "UrlCustomParameters" });

Predicate pred = new Predicate();
pred.setField("FeedId");
pred.setOperator(PredicateOperator.EQUALS);
pred.setValues(new String[]{<feedid>});
selector.setPredicates(new Predicate[] { pred });

int start = 0;
int pageSize = 5000;
Paging paging = new Paging();
paging.setNumberResults(pageSize);
paging.setStartIndex(start);
selector.setPaging(paging);

FeedItemPage page = feedService.get(selector);
List<com.adlucent.domain.Sitelink> allAdlSitelinks = new ArrayList<>();
if (page.getEntries() == null) {
    return allAdlSitelinks;
}
System.out.println("Found "+page.getTotalNumEntries()+" sitelinks");

while (page.getEntries() != null) {
    allAdlSitelinks.addAll(asAdlucentSitelinks(acctId, mapping, page.getEntries()));
    start = start+pageSize;
    paging.setStartIndex(start);
    page = feedService.get(selector);
}

return allAdlSitelinks;

HTH -
mm

Juergen Henning

unread,
Jun 29, 2015, 1:59:34 PM6/29/15
to adwor...@googlegroups.com
Hey Margaret,

can you please post the method "asAdlucentSitelinks"? I think the "magic" will be there.


Thanks for your help
Juergen

Am Samstag, 27. Juni 2015 01:03:18 UTC+2 schrieb mm:

mm

unread,
Jun 29, 2015, 2:06:06 PM6/29/15
to adwor...@googlegroups.com
Hey Juergen,
asAdlucentSitelinks is semantically the same as the getSiteLinksFromFeed method in that sample code you linked to (that code is actually probably clearer than mine)

-mm
Reply all
Reply to author
Forward
0 new messages