【问题标题】:"Access to this API has been disallowed" while querying Financial Times'查询《金融时报》时“禁止访问此 API”
【发布时间】:2019-05-30 21:47:48
【问题描述】:

如何通过他们的 API 获取 FT 文章?

在询问密钥后,我首先在他们的内容 API v2.1 中使用了a python API wrapper。所以我运行了以下内容:

from pyft import FT

ft = FT()
# the id can be pulled from the slug url of an FT.com story
content = ft.get_content("6f2ca3d6-86f5-11e4-982e-00144feabdc0")
print(content)

得到:

{'error': 'Access to this API has been disallowed'}

所以我关注了the official instructions,但得到了同样的错误:

【问题讨论】:

  • 您是否阅读了文档中有关密钥文件的部分并创建了它?
  • @KlausD。是的,这是我做的第一件事。它位于C:\Users\me\.ft.key

标签: python python-3.x api postman


【解决方案1】:

这应该是来自 FT 的错误。因为,get_content_notifications 没有任何问题。

notification = ft.get_content_notifications("2018-10-10T00:00:00.000Z")
print(notification)

{
"requestUrl": "https://api.ft.com/content/notifications?since=2018-10-10T00%3A00%3A00.000Z",
"notifications": [
    {
        "type": "http://www.ft.com/thing/ThingChangeType/UPDATE",
        "id": "http://www.ft.com/thing/e75d5a6c-b725-11e8-bbc3-ccd7de085ffe",
        "apiUrl": "https://api.ft.com/content/e75d5a6c-b725-11e8-bbc3-ccd7de085ffe"
    }
}

【讨论】:

  • 嗯,我得到{'error': 'Access to this API has been disallowed'}
  • 因为 FT 已阻止对其内容 API 的某些访问权限。 get_content_notifications 是否也出现同样的错误?
  • 是的,很遗憾
  • 您是否正确添加了密钥?您只需将访问代码粘贴到您的 .ft.key 文件中
【解决方案2】:

这是因为您的 API 密钥在 Headline License 下,它只允许访问有限的端点。因此,您应该考虑购买Datamining License 以访问更多的端点,包括代码中的“获取内容”。在此处查看更多信息:https://developer.ft.com/portal/docs-start-obtain-an-api-key

【讨论】:

    【解决方案3】:

    来自 FT.com 的说明

    • 下载 FT_API_Postman_Collection.json
    • 打开邮递员
    • 单击导入,单击选择文件并指定 FT_API_Postman_Collection.json。每个导入的集合都会显示导入成功消息
    • 点击眼睛图标设置环境
    • 点击添加
    • 输入环境名称。例如,FTAPI
    • 从上一步发送给您的电子邮件中复制您的 API 密钥
    • 输入键和值
    • 点击添加
    • 点击添加

    当您设置 FTAPI 环境时,请确保将变量命名为“KEY”,因为这是 Postman collection.json 中的名称

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-27
      • 2017-10-03
      • 1970-01-01
      • 1970-01-01
      • 2018-01-27
      • 1970-01-01
      • 1970-01-01
      • 2014-10-27
      相关资源
      最近更新 更多