【问题标题】:ChatFuel - Google Drive - Get file content using GET method via URLChatFuel - Google Drive - 使用 GET 方法通过 URL 获取文件内容
【发布时间】:2017-08-15 16:26:03
【问题描述】:

我正在开发一个 Fuel 聊天机器人,它可以从 Google 驱动器获取文件内容以构建图库。 我正在使用 JSON API(燃料聊天机器人)来获取 JSON 响应。 我在驱动器中的文件:https://drive.google.com/file/d/0Bx79Tkj95Q3iNmVHOFN0Q3BITE0/view 我想得到如下 JSON 响应:

{
 "messages": [
    {
      "attachment":{
        "type":"template",
        "payload":{
          "template_type":"generic",
          "elements":[
            {
              "title":"Classic White T-Shirt",
              "image_url":"http://petersapparel.parseapp.com/img/item100-thumb.png",
              "subtitle":"Soft white cotton t-shirt is back in style",
              "buttons":[
                {
                  "type":"web_url",
                  "url":"https://petersapparel.parseapp.com/view_item?item_id=100",
                  "title":"View Item"
                },
                {
                  "type":"web_url",
                  "url":"https://petersapparel.parseapp.com/buy_item?item_id=100",
                  "title":"Buy Item"
                }
              ]
            },
            {
              "title":"Classic Grey T-Shirt",
              "image_url":"http://petersapparel.parseapp.com/img/item101-thumb.png",
              "subtitle":"Soft gray cotton t-shirt is back in style",
              "buttons":[
                {
                  "type":"web_url",
                  "url":"https://petersapparel.parseapp.com/view_item?item_id=101",
                  "title":"View Item"
                },
                {
                  "type":"web_url",
                  "url":"https://petersapparel.parseapp.com/buy_item?item_id=101",
                  "title":"Buy Item"
                }
              ]
            }
          ]
        }
      }
    }
  ]
}

我尝试通过 URL 获取文件内容:

https://www.googleapis.com/drive/v3/files/0Bx79Tkj95Q3iNmVHOFN0Q3BITE0/export?mimeType=application/vnd.google-apps.file

但我得到了回应

您对获取 JSON 响应有什么建议吗?

【问题讨论】:

    标签: google-drive-api chatbot chatfuel


    【解决方案1】:

    考虑这个documentation 并再次测试。

    你的错误是:

    403:超出每日限制

    已达到您项目的礼貌 API 限制。

    {
      "error": {
        "errors": [
          {
            "domain": "usageLimits",
            "reason": "dailyLimitExceeded",
            "message": "Daily Limit Exceeded"
          }
        ],
        "code": 403,
        "message": "Daily Limit Exceeded"
      }
    }
    

    建议采取的措施:申请额外配额

    根据SO post,您可以执行以下操作来消除您的错误。

    1. 创建一个Google APIs Console project
    2. Services pane 上,启用您的项目所需的所有 API。
    3. API Access pane 上,点击创建 OAuth 2.0 客户端 ID。将打开一个对话框。填写您的项目信息。点击 下一步
    4. 选择适当的应用程序类型。根据您在这篇文章中使用的标签,我猜这是一个 iOS 项目,所以选择 已安装的应用程序
    5. 输入您的捆绑包 ID。在您的应用列出之前,您无需输入 App Store ID。
    6. 点击创建客户 ID

    您将看到客户端 ID 和客户端密码值。你将使用 这些值使您能够与您的项目和 Google 进行沟通 API。

    如果您还没有使用它,请参阅Google+ iOS SDK and documentation 了解完整的步骤。名为“写 时刻”在实现上类似,并演示了如何连接 在 iOS 项目中使用 Google+ REST API SDK。

    您需要指定 plus.me 的范围以获取配置文件 信息。

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多