简体   繁体   中英

Share articles on linkedin not working with new v2 Api's

We have an app where we are using social media share with Linkedin , earlier the app was using v1 Api and post share was working fine, but now all of the sudden it has stopped working. I checked on google seems like v1 Apis are now deprecated, so I tried using v2 api's. But now I am getting below error-:

Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: forbidden (403)" UserInfo={NSLocalizedDescription=Request failed: forbidden (403)

Below is the code where I am passing access permissions and all other parameters for getting access token.

 - (LIALinkedInHttpClient *)client {
        UIViewController *top = [UIApplication sharedApplication].keyWindow.rootViewController;
      //  [top presentViewController:secondView animated:YES completion: nil];

        LIALinkedInApplication *application = [LIALinkedInApplication applicationWithRedirectURL:@"https://com.xxxxxx.linkedin.oauth/oauth"
clientId:@"xxxxxxxxx"
clientSecret:@"xxxxxxxx"
state:@"xxxxxxxxx"                                                                                      
grantedAccess:@[@"w_member_social"]];

        return [LIALinkedInHttpClient clientForApplication:application presentingViewController:top.presentedViewController]; //[LIALinkedInHttpClient clientForApplication:application];
    }

v2 URL - : https://www.linkedin.com/oauth/v2/shared?/accessToken , here accessToken is the valid token value which is appended to the URL, when I check the value in console.

I am not getting how to make a valid request with v2 Api's, or if there are more parameters that we need to pass for new Api's, can anyone help me on this? Thanks in advance.

Kindly let me know if any other information is required.

According to LinkedIn Share API v2.0 , your HTTP call should be looked like this:

POST https://api.linkedin.com/v2/shares

json:

{
    "content": {
        "contentEntities": [
            {
                "entityLocation": "https://www.example.com/content.html",
                "thumbnails": [
                    {
                        "resolvedUrl": "https://www.example.com/image.jpg"
                    }
                ]
            }
        ],
        "title": "Test Share with Content"
    },
    "distribution": {
        "linkedInDistributionTarget": {}
    },
    "owner": "urn:li:person:324_kGGaLE",
    "subject": "Test Share Subject",
    "text": {
        "text": "Test Share!"
    }
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM