简体   繁体   English

分享有关linkedin 不适用于新v2 Api 的文章

[英]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.我们有一个应用程序,我们在其中使用Linkedin 的社交媒体共享,之前该应用程序使用v1 Api 并且帖子共享工作正常,但现在突然停止工作。 I checked on google seems like v1 Apis are now deprecated, so I tried using v2 api's.我查了谷歌似乎是v1的API现在已经过时了,所以我尝试使用V2的API。 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) Domain=com.alamofire.error.serialization.response Code=-1011 “请求失败:禁止(403)” UserInfo={NSLocalizedDescription=请求失败:禁止(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. v2 URL - : https://www.linkedin.com/oauth/v2/shared?/accessToken ,这里的accessToken是附加到 URL 的有效令牌值,当我在控制台中检查值时。

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?我不知道如何使用 v2 Api 发出有效请求,或者如果我们需要为新 Api 传递更多参数,有人可以帮助我吗? 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:根据LinkedIn Share API v2.0 ,您的 HTTP 调用应如下所示:

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

json: 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!"
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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