2015-04-03 71 views
0
ChannelBannerResource chBannerResource = new ChannelBannerResource(); 
chBannerResource.setKind("youtube#channelBannerResource"); 
chBannerResource.setEtag("JcMoTLb1iDZi7UYDRZDsYNLPWNA/X7zrV-CaEaRAq1KbyVYs4KQu6MU");    chBannerResource.setUrl("http://myimage.com/ram/channelbaner.jpg"); 
YouTube.ChannelBanners.Insert chbannerresponse = youtube.channelBanners().insert(chBannerResource);ChannelBannerResource res= chbannerresponse.execute(); 

    Error :- GoogleJsonResponseException code: 400 : contentDetails 
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request 
{ 
    "code" : 400, 
    "errors" : [ { 
    "domain" : "youtube.part", 
    "location" : "part", 
    "locationType" : "parameter", 
    "message" : "contentDetails", 
    "reason" : "unexpectedPart" 
    } ], 
    "message" : "contentDetails" 
} 

請幫我..........如何在Java中使用v3 Data Api插入YouTube頻道橫幅廣告?

回答

0
Channel myChannel = channelListResponse.getItems().get(0); 
     String channelId = myChannel.getId(); 
     System.out.println("channel id===" + channelId); 
     URL url = new URL(imageurl248X1152); 
     URLConnection conn = url.openConnection(); 
     InputStreamContent mediaContent = new InputStreamContent(
       "image/jpeg", conn.getInputStream()); 
     ChannelBannerResource chBannerResource = new ChannelBannerResource(); 
     YouTube.ChannelBanners.Insert chbannerresponse = youtube 
       .channelBanners().insert(chBannerResource, mediaContent); 
     ChannelBannerResource res = chbannerresponse.execute(); 
     System.out.println("res====" + res.getUrl()); 
     ChannelBrandingSettings channelBrandingSettings = new ChannelBrandingSettings(); 
     ChannelSettings channelSettings = new ChannelSettings(); 
     channelSettings.setDescription(des); 
     channelSettings.setKeywords(keyword); 
     channelSettings.setProfileColor(profilecolor); 
     ImageSettings imageSettings = new ImageSettings(); 
     imageSettings.setBannerExternalUrl(res.getUrl()); 
     channelBrandingSettings.setChannel(channelSettings).setImage(
       imageSettings); 
     Channel channel = new Channel(); 
     channel.setId(channelId); 
     channel.setBrandingSettings(channelBrandingSettings); 
     System.out.println("channel===" + channel); 
     Channel updateChannelResponse = youtube.channels() 
       .update("brandingSettings", channel).execute(); 
相關問題