在不支持新v2 Api的linkedin上共享文章

时间:2019-12-04 19:51:34

标签: ios objective-c swift linkedin linkedin-api

我们有一个应用程序,该应用程序正在与 Linkedin 进行社交媒体共享,早期该应用程序使用的是v1 Api,并且后期共享工作正常,但现在突然之间停止工作。我在Google上进行了检查,好像v1的Apis现在已被弃用,因此我尝试使用v2 api。但是现在我遇到了以下错误-:

  

Domain = com.alamofire.error.serialization.response代码= -1011“请求   失败:禁止(403)“ UserInfo = {NSLocalizedDescription = Request   失败:禁止(403)

下面是我传递访问权限和获取访问令牌的所有其他参数的代码。

 - (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,此处accessToken是当我在控制台中检查值时附加到URL的有效令牌值。

我没有获得如何使用v2 Api发出有效请求的方法,或者如果需要为新Api传递更多参数,那么有人可以帮我吗?预先感谢。

请告诉我是否需要其他信息。

1 个答案:

答案 0 :(得分:0)

根据LinkedIn Share API v2.0,您的HTTP调用应如下所示:

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