2014-09-30 73 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;