2014-09-30 3 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; 
Смежные вопросы