FeedAttribute urlAttribute = new FeedAttribute();
urlAttribute.setType(FeedAttributeType.URL);
urlAttribute.setName("Link URL");
// Create the feed.
Feed siteLinksFeed = new Feed();
siteLinksFeed.setName("Feed For Sitelinks");
siteLinksFeed.setAttributes(new FeedAttribute[] {textAttribute, urlAttribute});
siteLinksFeed.setOrigin(FeedOrigin.USER);
// Create operation.
FeedOperation operation = new FeedOperation();
operation.setOperand(siteLinksFeed);
operation.setOperator(Operator.ADD);
// Add the feed.
FeedReturnValue result = feedService.mutate(new FeedOperation[] {operation});
Feed savedFeed = result.getValue()[0];
siteLinksData.siteLinksFeedId = savedFeed.getId();
FeedAttribute[] savedAttributes = savedFeed.getAttributes();
siteLinksData.linkTextFeedAttributeId = savedAttributes[0].getId();
siteLinksData.linkUrlFeedAttributeId = savedAttributes[1].getId();
return siteLinksData;
}