2014-09-30 72 views
0

我正尝试在LinkedIn中分享一些内容。我得到了用户配置文件,但使用此代码,我不能分享讯息:在LinkedIn中的职位/分享状态

[self.client GET:[NSString stringWithFormat:@"https://api.linkedin.com/v1/people/~:(id,picture-url,email-address,first-name,last-name,headline,location,industry,positions,educations)?oauth2_access_token=%@&format=json", accessToken] parameters:nil success:^(AFHTTPRequestOperation *operation, NSDictionary *result) { 

     NSLog(@"current user %@", result); 

     [self.client POST:[NSString stringWithFormat:@"https://api.linkedin.com/v1/people/~/shares/?comment=test&title=commentTest&oauth2_access_token=%@&format=json",accessToken] parameters:nil success:^(AFHTTPRequestOperation *operation, NSDictionary *result) { 
      NSLog(@"result share %@",result); 
     } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 

      NSLog(@"failed to post %@", error); 
     }]; 

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

     NSLog(@"failed to fetch current user %@", error); 
    }]; 

我读过这个文档文章https://developer.linkedin.com/documents/writing-linkedin-apis,但我不理解的是,做他们的意思我们在请求中发布了一个完整的json或xml?如果是这样,你有解决方案吗?

回答

0

尝试添加内容类型接受到http标头。

AFJSONRequestSerializer *requestSerializer = [AFJSONRequestSerializer serializer]; 
[requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; 
[requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"]; 
self.client.requestSerializer = requestSerializer;