我正在使用下面的代码通过 twitvid 网站上传图片。但我收到错误
代码初始化。
- (void)awakeFromNib
{
[super awakeFromNib];
self.tv = [TwitVid twitVidWithSource:TwitVid_APP_ID
delegate:self];
}
这是上传图片的代码。
- (NSString *)authenticationHeaderForKey:(NSString *)key secret:(NSString *)secret URL:(NSString *)URL
{
OAConsumer *consumer = [[OAConsumer alloc] initWithKey:OAUTH_CONSUMER_KEY
secret:OAUTH_CONSUMER_SECRET];
OAToken *token = [[OAToken alloc] initWithKey:key
secret:secret];
OAMutableURLRequest *theRequest = [[OAMutableURLRequest alloc] initWithURL:[NSURL URLWithString:URL]
consumer:consumer
token:token
realm:nil
signatureProvider:nil];
[consumer release];
[token release];
[theRequest prepare];
[theRequest autorelease];
return [theRequest valueForHTTPHeaderField:@"Authorization"];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *authHeader = [self authenticationHeaderForKey:OAUTH_TOKEN_KEY
secret:OAUTH_TOKEN_SECRET
URL:SERVICE_PROVIDER];
self.alertView = [[[UIAlertView alloc] initWithTitle:@"Uploading"
message:@"\n \n"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil] autorelease];
if ([[info valueForKey:UIImagePickerControllerMediaType] isEqualToString:(id)kUTTypeMovie]) {
//Video
self.alertView.title = @"Uploading Video";
NSString *mediaPath = [[info valueForKey:UIImagePickerControllerMediaURL] path];
self.uploadRequest = [tv uploadWithMediaFileAtPath:mediaPath
offset:0
message:@"Your message"
mediaID:nil
playlistID:nil
vidResponseParent:nil
userTags:nil
geoLatitude:nil
geoLongitude:nil
tags:nil
categoryID:nil
description:nil
title:nil
xVerifyCredentialsAuthorization:authHeader
xAuthServiceProvider:SERVICE_PROVIDER];
}
else {
//Picture
self.alertView.title = @"Uploading Picture";
UIImage *editedImage = [info valueForKey:UIImagePickerControllerEditedImage];
NSString *imagePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"image.jpg"];
[[NSFileManager defaultManager] removeItemAtPath:imagePath error:nil];
[[NSFileManager defaultManager] createFileAtPath:imagePath
contents:UIImageJPEGRepresentation(editedImage, 0.8)
attributes:nil];
self.uploadRequest = [tv uploadPicWithMediaFileAtPath:imagePath
message:@"Your message"
mediaID:nil
userTags:nil
geoLatitude:nil
geoLongitude:nil
tags:nil
categoryID:nil
description:@"Image description"
title:@"Image title"
xVerifyCredentialsAuthorization:authHeader
xAuthServiceProvider:SERVICE_PROVIDER];
}
[self.alertView show];
[self dismissModalViewControllerAnimated:YES];
}
这是 twitvid 网站提供的确切代码。我只更改我的应用程序名称键。
现在它显示如下错误
'uploadPic' REQUEST '1i1gc0hr' DID FAIL WITH ERROR: Error Domain=TVErrorBackendDomain Code=1001 "Could not authenticate with OAuth." UserInfo=0x18ca10 {NSLocalizedDescription=Could not authenticate with OAuth.}
现在我很困惑,用户没有登录。这是如何工作的?
请帮我在 twitvid 上上传图片或视频。
我正在使用这个库:http ://twitvid.pbworks.com/w/file/fetch/44841746/TwitVidSDK-iOS.zip
提前致谢。
希瓦姆