在iOS中为vimeo视频添加评论

时间:2013-09-12 11:47:55

标签: ios objective-c vimeo

在我的ios应用程序中,当我尝试使用video.comment.addcomment为vimeo视频添加评论时,如果评论只有一个单词正在添加,但如果它是多个单词则表示错误无效签名。我使用的代码是:

NSString *new = [NSString stringWithString:commentis];
    new = [new stringByReplacingOccurrencesOfString:@" " withString:@"+"];
NSString *url12 = @"http://vimeo.com/api/rest/v2?format=json&method=vimeo.videos.comments.addComment&video_id=123456&comment_text=good";
url12 = [url12 stringByReplacingOccurrencesOfString:@"123456" withString:videoplaying];
url12 = [url12 stringByReplacingOccurrencesOfString:@"good" withString:new];

NSURL *urlinfo = [[NSURL alloc] initWithString:url12];
OAMutableURLRequest *request3 = [[OAMutableURLRequest alloc]initWithURL:urlinfo consumer:consumer token:tokenfi realm:nil signatureProvider:nil];

我明白错误。我得到的json回应是

{
err =     {
    code = 401;
    expl = "The oauth_signature passed was not valid.";
    msg = "Invalid signature";
};
"generated_in" = "0.0124";
stat = fail;
}

但是,如果我将评论作为单个单词给出,那么它的工作正常。

1 个答案:

答案 0 :(得分:2)

可能与whitespace以及您执行请求的方式有关。确保您正在格式化的URL中没有空格。

在使用字符串创建NSURL之前,使用URL转义码替换空格。像这样:

url12 = [url12 stringByReplacingOccurrencesOfString:@" " withString:@"%20"];