V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
chunyang
V2EX  ›  问与答

如何获取 Github 的提醒数量?

  •  
  •   chunyang · 2015-03-12 03:03:39 +08:00 · 2501 次点击
    这是一个创建于 3332 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我想在 Emacs 的 modeline 上显示我的 Github 未读提醒的数量(https://github.com/notifications ),我已经看了相关的 Github 的 API 文档,但是不知道如何如何获取 Github 的提醒数量。

    我试过了(其中 my-github-token 代表的是我的 token):

    ➜  ~  curl -H 'Authorization: token my-github-token' \
    > https://api.github.com/notifications
    {
      "message": "Missing the 'notifications' scope.",
      "documentation_url": "https://developer.github.com/v3"
    }
    

    可是,我没看到有关scope的相关文档,并且我也没有 web API 的使用经验,一时半会也弄不明白,大家有什么办法没?

    2 条回复    2015-03-12 12:37:34 +08:00
    orzfly
        1
    orzfly  
       2015-03-12 09:53:41 +08:00   ❤️ 1
    你的 token 是怎么生成的?如果是在网页版里生成个人 token的时候,是会让你选择权限的,就是一个有一大堆 checkbox 的列表,你得在那个列表里勾上 notifications。
    chunyang
        2
    chunyang  
    OP
       2015-03-12 12:37:34 +08:00
    @orzfly 我按照 Github 的教程生成的:
    ```
    $ curl -i -u <your_username> -d '{"scopes": ["repo", "user"], "note": "getting-started"}' \
    https://api.github.com/authorizations
    ```
    确实没有加 notifications,现在加上了,已经能用了。谢谢解答。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5284 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 08:04 · PVG 16:04 · LAX 01:04 · JFK 04:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.