【问题标题】:Fetch company posts from linkedin API从linkedin API获取公司帖子
【发布时间】:2021-06-16 20:37:02
【问题描述】:

我正在尝试从api中获取公司的帖子,我已经申请了营销开发平台并获得了批准。我已经获得了范围为 r_organization_social 的令牌,我正在调用 /shares api:

https://api.linkedin.com/v2/shares?q=owners&owners=urn:li:organization:{company_ID}&sharesPerOwner=100&count=25&sharesPerOwner=10

但我收到以下回复:

{
    "paging": {
        "start": 0,
        "count": 25,
        "links": [
            {
                "type": "application/json",
                "rel": "next",
                "href": "/v2/shares?count=25&owners=urn%3Ali%3Aorganization%3A{company_ID}&q=owners&sharesPerOwner=10&sharesPerOwner=100&start=0"
            }
        ],
        "total": 242
    },
    "elements": []
}

我尝试更改查询参数,但还是一样

【问题讨论】:

  • 根据this thread,可能是因为缺少标头 X-Restli-Protocol-Version: 2.0.0。就我而言,如果我包含它,我会收到另一个错误“参数所有者的值类型无效”,这似乎是已经报告的常见问题 (git issue)。如果您找到任何其他解决方案,请告诉我。

标签: linkedin linkedin-api


【解决方案1】:

这个端点对我有用:

https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List(urn%3Ali%3Aorganization%3A<ID_ORGANIZATION>)

查看文档:https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/ugc-post-api?tabs=http#sample-request-6

【讨论】:

  • ugcPost 端点是正确的选择,因为 LinkedIn 开发人员表示共享端点将在未来被弃用(如 here 所说)
【解决方案2】:

免责声明:我无法访问linkedin API,也无法测试。但这些是我注意到的一些事情:

您的网址包含两倍的参数sharesPerOwner,请尝试删除一个。

在文档中,建议将 sharePerOwner 设置为 1000,将计数设置为 50。我还包括 start 参数,以确保: 也许尝试这样的事情:

GET https://api.linkedin.com/v2/shares?q=owners&owners=urn:li:organization:{id}&sharesPerOwner=1000&count=50&start=0

来自 api-docs(https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/share-api?tabs=http#find-shares-by-owner):“请注意,分页不包括 UGC 和直接赞助内容 (DSC) 帖子”。确保您正在测试的所有者包含帖子。

如果这不起作用。您能否提供一些有关您如何发送请求的信息?您是否尝试过访问 api 的其他部分?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-02
    • 1970-01-01
    • 2019-06-26
    • 1970-01-01
    • 1970-01-01
    • 2018-11-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多