This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
austinv11's profile picture

Getting GitHub files in CC

Started by austinv11, 11 January 2014 - 08:56 AM
austinv11 #1
Posted 11 January 2014 - 09:56 AM
I was wondering how (if possible) to code a program so that it runs like the pastebin program, but it installs from GitHub.
Sorry if this is a noobish question, but I don't have much experience with the http api and GitHub (I only recently started using it)
austinv11 #2
Posted 11 January 2014 - 11:08 AM
Okay I may have fixed it, here's my code (not bug-tested):

function gitGet(user, repo, branch, path, toPath)
local dl = http.get("https://raw.github.com/"..user.."/"..repo.."/"..branch.."/"..path)
local file = dl.readAll()
dl.close()
local w = fs.open(toPath,"w")
w.write(file)
w.close()
return true
end

But is it possible to upload files?
awsmazinggenius #3
Posted 11 January 2014 - 12:45 PM
It is possible to make commits from ComputerCraft if you go through a server-side hosted script to use GitHub's OAuth API to give you access to your own account, then you can post the files in question to the server script. (I think you need the authorization info in a header, at least last time I worked with an OAuth API that was the case.)
Edited on 11 January 2014 - 11:46 AM
austinv11 #4
Posted 11 January 2014 - 12:56 PM
It is possible to make commits from ComputerCraft if you go through a server-side hosted script to use GitHub's OAuth API to give you access to your own account, then you can post the files in question to the server script. (I think you need the authorization info in a header, at least last time I worked with an OAuth API that was the case.)
Interesting, so is it possible for it to be self-contained in an API of mine?