最近,我有一些任务要集成开放源URL短服务。 我选择了Google提供的Firebase动态链接,但没有设法找到一些不错的教程或快速入门方法。 我设法执行了服务并获得了答案。 我希望获得一些有关客户端初始化的改进建议。
使用了渐变依赖
compile 'com.google.apis:google-api-services-firebasedynamiclinks:v1-rev860-1.25.0'
代码
FirebaseDynamicLinks.Builder builder = new FirebaseDynamicLinks.Builder(GoogleNetHttpTransport.newTrustedTransport(),
JacksonFactory.getDefaultInstance(), null);
FirebaseDynamicLinksRequestInitializer firebaseDynamicLinksRequestInitializer = new FirebaseDynamicLinksRequestInitializer(
"***WEB_API_KEY***");
builder.setApplicationName("***Fire_Bass_Dummy_App***");
builder.setFirebaseDynamicLinksRequestInitializer(firebaseDynamicLinksRequestInitializer);
FirebaseDynamicLinks firebasedynamiclinks = builder.build();
CreateShortDynamicLinkRequest createShortLinkRequest = new CreateShortDynamicLinkRequest();
createShortLinkRequest.setLongDynamicLink("***Dynamic_Links_domain***?link=***long_link***");
Suffix suffix = new Suffix();
suffix.setOption("SHORT");
createShortLinkRequest.setSuffix(suffix);
FirebaseDynamicLinks.ShortLinks.Create request = firebasedynamiclinks.shortLinks().create(createShortLinkRequest);
CreateShortDynamicLinkResponse createShortDynamicLinkResponse = request.execute();