実際にはOAuth 2.0を使用しています。 webnviewを使用してLinkedinログインページを表示し、URLをクライアントキーとして与え、その認証終了ポイント、レスポンスタイプ、および状態をWebビューで表示します。すべてが動作していますlinkedinのユーザーデータの取得に関する問題
-(void)requestforAccessToken:(NSString *)authorisationCode
{
NSString *grantType = @"authorization_code";
NSString *postParameter = [NSString stringWithFormat:@"grant_type=%@&code=%@&redirect_uri=%@&client_id=%@&client_secret=%@",grantType,authorisationCode,encodedRdirectURL,linkedInKey,linkedInSecret];
NSData *postdata = [postParameter dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:accessTokenEndPoint]];
request.HTTPMethod = @"POST";
request.HTTPBody = postdata;
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
manager.responseSerializer = [AFJSONResponseSerializer
serializerWithReadingOptions:NSJSONReadingAllowFragments];
[[manager dataTaskWithRequest:request completionHandler:^(NSURLResponse * response, id responseObject, NSError * error)
{
if (!error)
{
NSLog(@"Reply JSON: %@", responseObject);
NSString *accessToken = [responseObject objectForKey:@"access_token"];
NSLog(@"Access Token %@",accessToken);
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:accessToken forKey:@"linkedInAccessToken"];
[defaults synchronize];
}
}] resume];
}
この方法を使用すると、今私の質問は、プロファイルの写真とすべての基本データのようなユーザーデータを取得する方法です。 facebookのようなソリューションがあれば、accesstokenを追加してJSONデータを取得します。 LinkedInのSDKを使用したくない場合でも、直接のコミュニケーションが必要なので、助けてください。
[NSString stringWithFormat:@"https://api.linkedin.com/v1/people/~:(first-name,last-name,id,industry,location,headline,specialties,current-share,summary,picture-url,email-address,positions)?oauth2_access_token=%@&format=json", accessToken]
accessToken
はあなたがちょうど真偽の後に得るものです:あなた
公式LinkedInのドキュメントが何を言うん:あなたは、このようになりますJSON応答を言ったように、
はちょうどこのURLにAFNetworking
とGET
要求を行うと、あなたは受けるのでしょうか? – Ollie