In LinkedIn sharing,LinkedIn provide a SDK but using this SDK,I can't share image link and text it always shows
LISDKErrorAPIDomain Code=403 The operation couldn't be completed. (LISDKErrorAPIDomain error 403.)
Code:
NSString *url = @"https://api.linkedin.com/v1/people/~/shares";
NSString *payload = @"{\"comment\":\"Check out developer.linkedin.com! http://linkd.in/1FC2PyG\",\"visibility\":{ \"code\":\"anyone\" }}";
if ([LISDKSessionManager hasValidSession])
{
[[LISDKAPIHelper sharedInstance] postRequest:url stringBody:payload
success:^(LISDKAPIResponse *response) {
// do something with response
NSLog(@"response : %@",response.data);
}
error:^(LISDKAPIError *apiError) {
// do something with error
NSLog(@"error: %@",apiError);
}];
}
Sharing on LinkedIn Error : LISDKErrorAPIDomain Code=403 The operation couldn't be completed.
if you are repeating same static text to post on LinkedIn, it might be a change to getting same error.
you must get share permission before add post
NSArray *permissions = [NSArray arrayWithObjects:LISDK_BASIC_PROFILE_PERMISSION,LISDK_W_SHARE_PERMISSION, nil];
full login code
NSArray *permissions = [NSArray arrayWithObjects:LISDK_BASIC_PROFILE_PERMISSION,LISDK_W_SHARE_PERMISSION, nil];
[LISDKSessionManager createSessionWithAuth:permissions state:nil showGoToAppStoreDialog:YES successBlock:^(NSString *returnState){
NSLog(@"%s","success called!");
LISDKSession *session = [[LISDKSessionManager sharedInstance] session];
NSLog(@"Session : %@", session.description);
[[LISDKAPIHelper sharedInstance] getRequest:@"https://api.linkedin.com/v1/people/~"
success:^(LISDKAPIResponse *response) {
NSData* data = [response.data dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *dictResponse = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSString *authUsername = [NSString stringWithFormat: @"%@ %@", [dictResponse valueForKey: @"firstName"], [dictResponse valueForKey: @"lastName"]];
NSLog(@"Authenticated user name : %@", authUsername);
} error:^(LISDKAPIError *apiError) {
NSLog(@"Error : %@", apiError);
}];
} errorBlock:^(NSError *error) {
NSLog(@"Error called : %@", error);
}];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.