Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
错误:使用LinkedIn REST Api for iOS时喜欢/不喜欢和注释_Ios_Iphone_Rest_Linkedin - Fatal编程技术网

错误:使用LinkedIn REST Api for iOS时喜欢/不喜欢和注释

错误:使用LinkedIn REST Api for iOS时喜欢/不喜欢和注释,ios,iphone,rest,linkedin,Ios,Iphone,Rest,Linkedin,使用REST Api for iOS进行喜欢/不喜欢和评论 我使用下面的url和模式来喜欢网络帖子。我得到的答复是: “无法分析JSON文档” 。如果我在url中输入'is like=true',我会收到以下消息: “资源{Update}中的未知字段{is like=true}” 。我不知道一定是怎么了。请帮忙 这是我的密码: updateKey= @"UNIU-c1028-5809277741404942336-SHARE"; NSURL *url = [NSURL URLWithString

使用REST Api for iOS进行喜欢/不喜欢和评论 我使用下面的url和模式来喜欢网络帖子。我得到的答复是:

“无法分析JSON文档”

。如果我在url中输入'is like=true',我会收到以下消息:

“资源{Update}中的未知字段{is like=true}”

。我不知道一定是怎么了。请帮忙

这是我的密码:

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"];

好吧,我把这个留给有类似问题的人。罪魁祸首是HTTPBody,它没有为
is like
键添加“
true

所以我手动添加了true for is like,这就成功了

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"];
NSURL*url=[NSURL URLWithString:[NSString stringWithFormat:@]http://api.linkedin.com/v1/people/~/network/updates/key=%@/is like”,updateKey]];
OAMutableURLRequest*请求=
[[OAMutableURLRequest alloc]initWithURL:url
消费者:自我消费者
令牌:self.token
回拨:无
签名提供者:无];
[请求设置值:@“应用程序/json”用于HttpHeaderField:@“内容类型”];

[请求setHTTPBodyWithString:@“true”];// 我也遇到了同样的问题,在花了很多时间使用NSMutableURLRequest并结合的AFHTTPRequestOperation之后,我找到了解决方案。请尝试以下代码:

    NSString *stringRequest = @"https://api.linkedin.com/v1/people/~/shares?oauth2_access_token=ACCESS_TOKEN&format=json";

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:stringRequest]];
    [request setHTTPMethod:@"PUT"];
    [request setHTTPBody:[@"true" dataUsingEncoding:NSUTF8StringEncoding]]; //set true or false according to like-unlike request.
    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];

    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {

        NSLog(@"result: %@", responseObject);

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

        NSLog([error localizedDescription]);  
    }];
    [operation start];