【问题标题】:Post/Share status in LinkedIn在 LinkedIn 中发布/分享状态
【发布时间】:2014-09-30 15:59:29
【问题描述】:

我正在尝试在 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?如果是这样,您有解决方案吗?

【问题讨论】:

    标签: ios objective-c linkedin


    【解决方案1】:

    尝试将 Content-TypeAccept 添加到 http 标头。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-14
      • 1970-01-01
      • 2011-12-14
      • 1970-01-01
      • 2014-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多