错误:使用iOS版LinkedIn REST Api进行点赞/点赞和评论 [英] Error: Like/Unlike and Comment using LinkedIn REST Api for iOS

查看:81
本文介绍了错误:使用iOS版LinkedIn REST Api进行点赞/点赞和评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用REST Api(适用于iOS)喜欢/不喜欢和评论 我正在使用以下url和模式来喜欢网络帖子.我得到的响应为

Like/Unlike and Comment using REST Api for iOS I'm using the following url and pattern for liking a network post. I get the response as

无法解析与JSON相似的文档"

"Can not parse JSON is-liked document"

.如果我在网址中输入"is-liked = true",则会显示以下消息:

. If I make 'is-liked=true' in the url I get the message:

资源{Update}中的未知字段{is-liked = true}"

"Unknown field {is-liked=true} in resource {Update}"

.我不知道那一定是错的.请帮忙.

. I don't know what must be wrong. Please help.

这是我的代码:

updateKey= @"UNIU-c1028-5809277741404942336-SHARE";
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://api.linkedin.com/v1/people/~/network/updates/key=%@/is-liked",updateKey]];
OAMutableURLRequest *request =
[[OAMutableURLRequest alloc] initWithURL:url
consumer:self.consumer
token:self.token
callback:nil
signatureProvider:nil];

[request setValue:@"json" forHTTPHeaderField:@"x-li-format"];
[request setHTTPMethod:@"PUT"];

推荐答案

好的,我留给有类似问题的人使用.罪魁祸首是没有为is-Liked键添加'true'的HTTPBody.

Alright, I'm leaving this for people having a similar issue. The culprit was the HTTPBody that was not appending 'true' for is-Liked key.

因此,我为is-Liked手动添加了true,并且成功了.

So I added true for is-Liked manually and that did the trick.

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://api.linkedin.com/v1/people/~/network/updates/key=%@/is-liked",updateKey]];
    OAMutableURLRequest *request =
    [[OAMutableURLRequest alloc] initWithURL:url
                                    consumer:self.consumer
                                       token:self.token
                                    callback:nil
                           signatureProvider:nil];

    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBodyWithString:@"true"];// <-this is the magic wand!
    [request setHTTPMethod:@"PUT"];

这篇关于错误:使用iOS版LinkedIn REST Api进行点赞/点赞和评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆