我正在尝试向 youtube 发送发布请求,以将视频添加到收藏列表。API文档在这里
这是我的源代码:
- (void) addVideoToFavoriteWithID:(NSString *)strVideoID{
NSString* strConnection = [NSString stringWithFormat:@"%@%@",CONNECTION_YOUTUBE, CONNECTION_ADD_VIDEO_TO_FAVORITE];
AppDelegate* delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
ASIFormDataRequest *formData = [[ASIFormDataRequest alloc]initWithURL:[NSURL URLWithString:strConnection]];
[formData setRequestMethod:@"POST"];
[formData setPostValue:@"2" forKey:@"GData-Version"];
[formData setPostValue:@"application/atom+xml" forKey:@"Content-Type"];
[formData setPostValue:YOUTUBE_DEVELOPER_KEY forKey:@"X-GData-Key"];
[formData setPostValue:[[delegate userInfo ]accessTokenYoutube] forKey:@"Authorization"];
NSString *body = [NSString stringWithFormat:@"<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom'><id>%@</id></entry>",strVideoID];
[formData setPostValue:body forKey:@"body" ];
[formData setDelegate:self];
[formData setDidFinishSelector:@selector(didAddVideoToFavoriteFinish:)];
[formData setDidFailSelector:@selector(didAddVideoToFavoriteFail:)];\
[formData setDidReceiveDataSelector:@selector(didAddVideoToFavoriteSelect:)];
[formData startAsynchronous];
[formData release];
}
在方法didAddVideoToFavoriteFinish
中,我收到消息:
HTTP/1.1 415 不支持的媒体类型
请告诉我我的错误是什么。我是目标 C 的新手,我对此感到非常困惑。