【问题标题】:Adding comment to vimeo videos in iOS在 iOS 中为 vimeo 视频添加评论
【发布时间】:2013-09-12 11:47:54
【问题描述】:

在我的 ios 应用程序中,当我尝试使用 video.comment.addcomment 将 cmets 添加到 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;
}

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

【问题讨论】:

    标签: ios objective-c vimeo


    【解决方案1】:

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

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

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

    【讨论】:

    • 具体来说,错误是用加号替换空格。 OAuth 1 需要签名和查询字符串才能使用 RFC3986,tools.ietf.org/html/rfc3986,它将空格更改为 %20
    • @Dashron 感谢您的澄清!
    猜你喜欢
    • 2013-01-16
    • 2011-12-28
    • 2021-10-03
    • 1970-01-01
    • 2012-02-04
    • 1970-01-01
    • 2012-12-17
    • 1970-01-01
    • 2015-11-04
    相关资源
    最近更新 更多