如果我在 Youtube 上使用视频,google 营销 api 如何填充 AdVideoAsset 对象
If i use the video on Youtube, how does the google marketing api fill the AdVideoAsset object
private void createAppAd(
GoogleAdsClient googleAdsClient, long customerId, String adGroupResourceName) {
// Set up video
AdVideoAsset adVideoAsset = AdVideoAsset.newBuilder().setAsset("").build();
AppAdInfo appAdInfo = AppAdInfo.newBuilder()
.addAllHeadlines(
ImmutableList.of(
AdTextAsset.newBuilder().setText("test").build(),
AdTextAsset.newBuilder().setText("test").build()))
.addAllDescriptions(
ImmutableList.of(
AdTextAsset.newBuilder().setText("test").build(),
AdTextAsset.newBuilder().setText("test").build()))
.addYoutubeVideos()
.build();
Ad ad = Ad.newBuilder().setAppAd(appAdInfo).build();
AdGroupAd adGroupAd =
AdGroupAd.newBuilder()
.setStatus(AdGroupAdStatusEnum.AdGroupAdStatus.ENABLED)
.setAdGroup(adGroupResourceName)
.setAd(ad)
.build();
AdGroupAdOperation operation = AdGroupAdOperation.newBuilder().setCreate(adGroupAd).build();
try (AdGroupAdServiceClient adGroupAdServiceClient =
googleAdsClient.getLatestVersion().createAdGroupAdServiceClient()) {
MutateAdGroupAdsResponse response =
adGroupAdServiceClient.mutateAdGroupAds(
Long.toString(customerId), ImmutableList.of(operation));
log.info("Created an ad group ad with ad with resource name '%s'%n", response.getResults(0).getResourceName());
}
}
我查文档的时候没有找到上传的接口,也没有从youtube获取material,结果填入了assert字段AdVideoAsset.
AdVideoAsset adVideoAsset = AdVideoAsset.newBuilder().setAsset("").build();
期待您的回答
我已经通过查看官方文档解决了这个问题
这是我的测试代码
- 创建 YouTube 视频资产和return资产 ID
// Create a YouTube video asset and return the asset ID,eg:customers/xxxxxxxxxxx/assets/17064058414
public String createYoutubeVideoAssert(Long customerId, String youtubeVideoId) throws IOException {
GoogleAdsClient googleAdsClient = googleAdsClientRegister.getClient();
YoutubeVideoAsset youtubeVideoAsset = YoutubeVideoAsset.newBuilder()
.setYoutubeVideoId(youtubeVideoId)
.build();
Asset asset =
Asset.newBuilder()
.setName("Jupiter Trip # " + "1234")
.setType(AssetTypeEnum.AssetType.YOUTUBE_VIDEO)
.setYoutubeVideoAsset(youtubeVideoAsset)
.build();
AssetOperation operation = AssetOperation.newBuilder().setCreate(asset).build();
try (AssetServiceClient assetServiceClient =
googleAdsClient.getVersion7().createAssetServiceClient()) {
MutateAssetsResponse response =
assetServiceClient.mutateAssets(Long.toString(customerId), ImmutableList.of(operation));
System.out.printf(
"The youtube video asset with resource name '%s' was created.%n",
response.getResults(0).getResourceName());
return response.getResults(0).getResourceName();
}
}
- 创建广告组广告
AdVideoAsset adVideoAsset = AdVideoAsset.newBuilder()
.setAsset("customers/xxxxxxxxxxx/assets/17064058414")
.build();
在对接Google广告的过程中,我们遇到了很多问题。有兴趣可以交流
private void createAppAd(
GoogleAdsClient googleAdsClient, long customerId, String adGroupResourceName) {
// Set up video
AdVideoAsset adVideoAsset = AdVideoAsset.newBuilder().setAsset("").build();
AppAdInfo appAdInfo = AppAdInfo.newBuilder()
.addAllHeadlines(
ImmutableList.of(
AdTextAsset.newBuilder().setText("test").build(),
AdTextAsset.newBuilder().setText("test").build()))
.addAllDescriptions(
ImmutableList.of(
AdTextAsset.newBuilder().setText("test").build(),
AdTextAsset.newBuilder().setText("test").build()))
.addYoutubeVideos()
.build();
Ad ad = Ad.newBuilder().setAppAd(appAdInfo).build();
AdGroupAd adGroupAd =
AdGroupAd.newBuilder()
.setStatus(AdGroupAdStatusEnum.AdGroupAdStatus.ENABLED)
.setAdGroup(adGroupResourceName)
.setAd(ad)
.build();
AdGroupAdOperation operation = AdGroupAdOperation.newBuilder().setCreate(adGroupAd).build();
try (AdGroupAdServiceClient adGroupAdServiceClient =
googleAdsClient.getLatestVersion().createAdGroupAdServiceClient()) {
MutateAdGroupAdsResponse response =
adGroupAdServiceClient.mutateAdGroupAds(
Long.toString(customerId), ImmutableList.of(operation));
log.info("Created an ad group ad with ad with resource name '%s'%n", response.getResults(0).getResourceName());
}
}
我查文档的时候没有找到上传的接口,也没有从youtube获取material,结果填入了assert字段AdVideoAsset.
AdVideoAsset adVideoAsset = AdVideoAsset.newBuilder().setAsset("").build();
期待您的回答
我已经通过查看官方文档解决了这个问题
这是我的测试代码
- 创建 YouTube 视频资产和return资产 ID
// Create a YouTube video asset and return the asset ID,eg:customers/xxxxxxxxxxx/assets/17064058414
public String createYoutubeVideoAssert(Long customerId, String youtubeVideoId) throws IOException {
GoogleAdsClient googleAdsClient = googleAdsClientRegister.getClient();
YoutubeVideoAsset youtubeVideoAsset = YoutubeVideoAsset.newBuilder()
.setYoutubeVideoId(youtubeVideoId)
.build();
Asset asset =
Asset.newBuilder()
.setName("Jupiter Trip # " + "1234")
.setType(AssetTypeEnum.AssetType.YOUTUBE_VIDEO)
.setYoutubeVideoAsset(youtubeVideoAsset)
.build();
AssetOperation operation = AssetOperation.newBuilder().setCreate(asset).build();
try (AssetServiceClient assetServiceClient =
googleAdsClient.getVersion7().createAssetServiceClient()) {
MutateAssetsResponse response =
assetServiceClient.mutateAssets(Long.toString(customerId), ImmutableList.of(operation));
System.out.printf(
"The youtube video asset with resource name '%s' was created.%n",
response.getResults(0).getResourceName());
return response.getResults(0).getResourceName();
}
}
- 创建广告组广告
AdVideoAsset adVideoAsset = AdVideoAsset.newBuilder()
.setAsset("customers/xxxxxxxxxxx/assets/17064058414")
.build();
在对接Google广告的过程中,我们遇到了很多问题。有兴趣可以交流