chunyang
V2EX  ›  问与答

如何获取 Github 的提醒数量?

  •  
  •   chunyang · Mar 12, 2015 · 3298 views
    This topic created in 4081 days ago, the information mentioned may be changed or developed.

    我想在 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 replies    2015-03-12 12:37:34 +08:00
    orzfly
        1
    orzfly  
       Mar 12, 2015   ❤️ 1
    你的 token 是怎么生成的?如果是在网页版里生成个人 token的时候,是会让你选择权限的,就是一个有一大堆 checkbox 的列表,你得在那个列表里勾上 notifications。
    chunyang
        2
    chunyang  
    OP
       Mar 12, 2015
    @orzfly 我按照 Github 的教程生成的:
    ```
    $ curl -i -u <your_username> -d '{"scopes": ["repo", "user"], "note": "getting-started"}' \
    https://api.github.com/authorizations
    ```
    确实没有加 notifications,现在加上了,已经能用了。谢谢解答。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5493 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 09:01 · PVG 17:01 · LAX 02:01 · JFK 05:01
    ♥ Do have faith in what you're doing.