【问题标题】:NSLocalizedDescription=Could not authenticate with OAuth.. error when using twitvid objective c libraryNSLocalizedDescription=Could not authenticate with OAuth.. 使用 twitvid 目标 c 库时出错
【发布时间】:2012-05-23 01:09:38
【问题描述】:

我正在使用以下代码通过 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

提前致谢。

湿婆

【问题讨论】:

  • 如果你得到答案后我也面临同样的问题..

标签: iphone objective-c video twitter


【解决方案1】:

你已经发布了请求,要么在类级别,即属性,要么试试这个

OAMutableURLRequest *theRequest = [[[OAMutableURLRequest alloc] initWithURL:[NSURL URLWithString:URL]
                                                                       consumer:consumer
                                                                         token:token
                                                                         realm:nil
                                                             signatureProvider:nil] autorlease];

    return [theRequest valueForHTTPHeaderField:@"Authorization"];

【讨论】:

  • 我已经以这种方式进行了更改,但结果仍然相同...是否有任何可用的工作库。
  • 你想要什么?我的意思是你要验证什么,FB?
  • 我必须在 twitvid 网站上上传图片和视频文件。
猜你喜欢
  • 2015-08-26
  • 2013-07-29
  • 2017-11-19
  • 2022-12-02
  • 2019-12-18
  • 1970-01-01
  • 1970-01-01
  • 2017-07-11
  • 1970-01-01
相关资源
最近更新 更多