【问题标题】:Share articles on linkedin not working with new v2 Api's分享有关linkedin 的文章不适用于新的v2 Api
【发布时间】:2020-03-29 17:02:34
【问题描述】:

我们有一个应用程序,我们正在使用 Linkedin 进行社交媒体分享,之前该应用程序使用 v1 Api 并且帖子分享工作正常,但现在突然停止工作.我在 google 上查了一下,似乎 v1 API 现在已被弃用,所以我尝试使用 v2 api。但是现在我遇到了错误-:

域=com.alamofire.error.serialization.response Code=-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 传递更多参数,有人可以帮助我吗?提前致谢。

如果需要任何其他信息,请告诉我。

【问题讨论】:

  • 这是objective-c代码,也许你应该为这个问题改变你的标签。

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


【解决方案1】:

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

【讨论】:

  • 你用这个网址测试过吗?
  • json 正文是实际的服务器响应?还是我们在调用时需要传递的参数体结构?
  • 是我们在调用时需要传递的参数体结构,而不是响应。
猜你喜欢
  • 2019-09-22
  • 2019-07-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-06-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多