如何为LinkedIn生成访问令牌?

时间:2015-12-16 13:48:24

标签: ios objective-c linkedin linkedin-api

我很想做"与linkedIn"分享来自我的iOS应用程序。"

  

如何在共享链接之前生成访问权限,如何进行   生成它?

这是我在链接中发布的代码。但它不起作用,因为我没有访问令牌。

// For positing on linked In

    [[LISDKAPIHelper sharedInstance] apiRequest:@"https://api.linkedin.com/v1/people/~/shares?format=json" method:@"POST" body:[bodyTxtView.text dataUsingEncoding:NSUTF8StringEncoding]
                success:^(LISDKAPIResponse *response)
                 {
                     NSLog(@"success called %@", response.data);
                }
              error:^(LISDKAPIError *apiError) {
                   NSLog(@"error called %@", apiError.description);

                    dispatch_sync(dispatch_get_main_queue(), ^{
                        LISDKAPIResponse *response = [apiError errorResponse];
                                                  NSString *errorText;
                              if (response)
                              {
                                    errorText = response.data;
                               }
                               else
                               {
                                   errorText = apiError.description;
                                }
                        NSLog(@"error called %@", errorText);
                 });
          }];

2 个答案:

答案 0 :(得分:0)

示例代码在SDK(内部示例应用程序)中给出,该代码是从https://developer.linkedin.com/downloads

下载的

答案 1 :(得分:-1)

你可以用这个课可能对你有所帮助!!   apikey = @" 75pxdmwh5ghbil&#34 ;;     secretkey = @" j3iYOXotT37VhPbM&#34 ;;

consumer = [[OAConsumer alloc] initWithKey:apikey
                                    secret:secretkey
                                     realm:@"http://api.linkedin.com/"];

requestTokenURLString = @"https://api.linkedin.com/uas/oauth/requestToken";
accessTokenURLString = @"https://api.linkedin.com/uas/oauth/accessToken";
userLoginURLString = @"https://www.linkedin.com/uas/oauth/authorize";    
linkedInCallbackURL = @"hdlinked://linkedin/oauth";

requestTokenURL = [[NSURL URLWithString:requestTokenURLString] retain];
accessTokenURL = [[NSURL URLWithString:accessTokenURLString] retain];
userLoginURL = [[NSURL URLWithString:userLoginURLString] retain];