Tag: github api

github说不能parsingjson,而在rest api中创build一个repo

我正在学习GitHub的REST api,并试图通过运行JS创build一个新的存储库。 这里是我创build一个新的回购的function:令牌生成,并且所有访问/作用域被授予我的令牌。 function createNewRepo(userId, name){ var options = { url: urlRoot + "/user/repos", method: 'POST', headers: { "User-Agent": "EnableIssues", "content-type": "application/json", "Authorization": token, "name": name, "description": "This is repo creating by REST", "homepage": "https://github.com", "private": false, "has_issues": true, "has_projects": true, "has_wiki": true, } }; //console.log(eval(options)); request(options, function (error, response, body) { var obj = […]

GitHub限速防止用户提交历史logging的返回

我写了代码来返回用户已经提交给GitHub的“连胜”(连续多less天)。 不幸的是,它是recursion地制作GitHub API请求,最终很快就会遇到速度限制问题(甚至是API令牌)。 有没有更好的方法来检索这些信息? 本质上,我正在寻找的是显示在用户帐户页面上的“绿色方块”数据: 我的示例代码正在进入速率限制: const express = require('express'); const request = require('request'); const moment = require('moment'); require('dotenv').config(); const app = express(); const port = 5000; app.get('/streak/:user', async function (req, res) { const yesterdaysDate = moment().subtract(1, 'day').format('YYYY-MM-DD'); try { const streakCountTotal = await checkUserCommitForDate(req.params.user, yesterdaysDate); res.send({ streakCountTotal }); } catch (error) { console.log(error); res.sendStatus(500); […]

Github API端点不能按预期工作

我们正在构build一个节点应用程序,在这里我们从Github API端点api.github.com/user/issues中获得特定authentication用户的问题。 这是行不通的,当我们在postman( https://www.getpostman.com/ )中testingGithub API端点时,我们会收到相同的消息: { "message": "Not Found", "documentation_url": "https://developer.github.com/v3" } 如果有人有使用这个端点的经验,我们将非常感激的帮助。

通过github APIasynchronousrecursion来获取文件

我正在使用github API来遍历一个repo并获取其中的所有文件的列表。 这个结构被称为“树”。 一棵树基本上是一个子目录。 所以如果我想看到一个树的内容,我需要对该树的ID进行GET请求。 响应将是表示该树中项目的对象数组。 但是其中一些项目也是树木,所以我不得不再次请求那棵树。 回购可能是这样的: |src app.jsx container.jsx |client index.html readme.md 这个结构将由以下对象来表示 [ { name:'src', type:'tree', id:43433432 }, { name:'readme.md', type:'md', id:45489898 } ] //a GET req to the id of the first object would return the following array: [ { name:'app.jsx', type:'file', id:57473738 }, { name:'contain.jsx', type:'file', id:748433454 }, { name:'client', […]

GitHub Webhook秘密从不validation

我正在使用GitHub webhook将事件传递给我的应用程序(GitHub的Hubot的一个实例),并使用sha1秘密进行保护。 我正在使用下面的代码来validation传入webhooks上的散列 crypto = require('crypto') signature = "sha1=" + crypto.createHmac('sha1', process.env.HUBOT_GITHUB_SECRET).update( new Buffer request.body ).digest('hex') unless request.headers['x-hub-signature'] is signature response.send "Signature not valid" return 在webhook中通过的X-Hub-Signature头看起来像这样 X-Hub-Signature:sha1 = 1cffc5d4c77a3f696ecd9c19dbc2575d22ffebd4 我按照GitHub的文档准确地传递了密钥和数据,但散列总是不一样。 这是GitHub的文档。 https://developer.github.com/v3/repos/hooks/#example 这是我最有可能误解的部分 secret:作为X-Hub-Signature标头与HTTP请求一起传递的可选string。 这个头部的值是作为身体的HMAChex摘要计算的,使用秘密作为密钥。 任何人都可以看到我要去哪里错了?

向Github API发送Post请求以创build问题不起作用

在过去的几天里,我一直在尝试向github api发出这个请求,但不幸的是,这个响应回来的时候是“坏消息” 这里是我们在发送请求中使用https请求在节点中发送的代码段 – 这是发布数据 var issueData = JSON.stringify({ "title":title, "body":comment }); 这是选项文件 var options = { host: 'api.github.com', path: '/repos/sohilpandya/katasohil/issues?access_token='+sessions.token, headers: { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0', }, method: 'POST' }; 这是https请求 var requestaddIssue = https.request(options, function(responseFromIssues){ responseFromIssues.setEncoding('utf8'); responseFromIssues.on('data', function(chunk){ console.log('>>>>chunk>>>>>',chunk); issueBody += chunk; }); responseFromIssues.on('end',function(issueBody){ console.log(issueBody); }); […]