【问题标题】:I face serviceErrorCode Error, when post on LinkedIn company page with rest API当我在 LinkedIn 公司页面上使用 rest API 发布时,我遇到了 serviceErrorCode 错误
【发布时间】:2022-07-06 19:38:46
【问题描述】:

我在使用 LinkedIn Rest API 时遇到错误。我尝试在我的公司页面上发布。我面临错误。当我在我的 LinkedIn 个人资料上发帖时。那也行。但是在公司页面我显示一个错误。

错误

{
  "serviceErrorCode": 100,
  "message": "Field Value validation failed in REQUEST_BODY: Data Processing Exception while processing fields [/owner]",
  "status": 403
}

详情

我使用共享 API,API URL https://api.linkedin.com/v2/shares。我的错误与 "owner": "urn: li: organization:76615898" 有关。我通过了,我的公司页面https://www.linkedin.com/company/76615898/

{
    "content": {
        "contentEntities": [
            {
                "entityLocation": "https://officialrajdeepsingh.dev/how-to-create-web-stories-on-ghost-cms/",
                "thumbnails": [
                    {
                        "resolvedUrl": "https://officialrajdeepsingh.dev/content/images/size/w2000/2022/02/Amp-ghost-cms--configation.png"
                    }
                ]
            }
        ],
        "title": "How to create web stories on Ghost CMS",
        "description": "The google web story helps websites to grow very fast. We enable AMP web stories on your website for free in the post."
    },
    "distribution": {
        "linkedInDistributionTarget": {}
    },
    "owner": "urn:li:organization:76615898",
    "subject": "The google web story helps websites to grow very fast. We enable AMP web stories on your website for free in the post.",
    "text": {
        "text": "How to create web stories on Ghost CMS"
    }
}

步骤

  1. 获取代码

  2. 获取访问令牌

获取代码

我使用get方法创建成功的代码。

    GET https://www.linkedin.com/oauth/v2/authorization? 
response_type=code&client_id=77d*******oo56&redirect_uri=https://officialrajdeepsingh.dev&state=testfoobar&scope=r_liteprofile%2520r_emailaddress%2520w_member_social

获取访问令牌

我使用post命令成功获取访问令牌

POST https://www.linkedin.com/oauth/v2/accessToken HTTP/1.1
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
code=code-here
redirect_uri=https://officialrajdeepsingh.dev
client_id=77d*********56
client_secret=ma***********Ch

基于令牌,我尝试在我的 LinkedIn 页面上创建一个帖子。

权限

  1. OAuth 2.0 范围

  2. 产品

OAuth 2.0 范围

对于权限,我添加了 3 个权限,以在 LinkedIn 页面上创建帖子。

产品

我将这三种产品都添加到我的应用中。

我不知道,代码中发生了什么。我还使用 ugcPosts 端点在我的公司页面上分享帖子。但不工作。 https://api.linkedin.com/v2/ugcPosts 使用 ugcPosts,我也面临错误

{
  "serviceErrorCode": 100,
  "message": "Field Value validation failed in REQUEST_BODY: Data Processing Exception while processing fields [/author]",
  "status": 403
}

请告诉我如何解决分享https://api.linkedin.com/v2/shares点的错误以及如何解决。

【问题讨论】:

    标签: rest linkedin linkedin-api


    【解决方案1】:

    这对我有用:

    我使用 Oauth 工具在 CURL 请求中创建了一个访问令牌。 https://www.linkedin.com/developers/tools/oauth?clientId=YOUR_CLIENT_ID

    保存访问令牌和访问刷新后,我被重定向以添加允许代表我(我的linkedin 用户)发布(通过 API)的权限。

    这样做后,您表明您已允许您的应用以您的名义发布。您可以在以下位置进行检查: https://www.linkedin.com/mypreferences/d/data-sharing-for-permitted-services

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-13
      • 1970-01-01
      相关资源
      最近更新 更多