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

[HTTP][Lua] Post to GitHub

Started by theoriginalbit, 10 January 2013 - 10:14 PM
theoriginalbit #1
Posted 10 January 2013 - 11:14 PM
Seems that it is the time for me to require help…

Hello all, I have been developing a GitHub suite and have almost got the issue reporter feature implemented…
Details of the GitHub API, specifically creating an issue, are here

My issue is that I have never had to post such detailed and specific data (well this detailed and specific anyway) to a website before. So my question is, what is the url format for this? This is what I got, and how the data is stored in the program. I know that I have to encode the data in some way for the URL… just not sure how…



local function submit_report(user, repo, report )
  local query = "https://api.github.com/repos/"..user.."/"..repo.."/issues/"..report
  http.post(query)
end


local titleText = ""
local bodyText = ""
local assigneeText = ""
local labels = {}




This is what it looks like (not that effects anything, just felt like showing you guys)
Spoiler
zekesonxx #2
Posted 11 January 2013 - 04:01 AM
I like your interface, how are you doing it? I'd love to know.

And you can't work with the GitHub API. It requires OAuth 2, which needs modification of HTTP headers. ComputerCraft doesn't have this feature.
theoriginalbit #3
Posted 11 January 2013 - 04:09 AM
zekesonxx said:
I like your interface, how are you doing it? I'd love to know.

Very messy for how I normally do it! Normally I have it very managed and screens know all elements and their location… this is just a literal code up and print where it is and check where it has been clicked… if you want to see exactly how just check out my repo here this is normally how I deal with guis here

zekesonxx said:
And you can't work with the GitHub API. It requires OAuth 2, which needs modification of HTTP headers. ComputerCraft doesn't have this feature.
I knew I wasn't doing anything wrong, i'd tried heaps of things. And i hoped this would work. i know that you can get things with the GitHub API. was hoping you could post stuff too. :/
Edited on 11 January 2013 - 03:12 AM
Orwell #4
Posted 11 January 2013 - 04:32 AM
I once had the crazy idea of implementing the git http protocol. It's specifications are huge, but if you could finish that, you'd have true git (push,pull,branch,…) and it would work with any online repository manager that supports git. :P/>
theoriginalbit #5
Posted 11 January 2013 - 04:38 AM
I once had the crazy idea of implementing the git http protocol. It's specifications are huge, but if you could finish that, you'd have true git (push,pull,branch,…) and it would work with any online repository manager that supports git. :P/>
As in peripheral (Java) or Lua? o.O
Orwell #6
Posted 11 January 2013 - 04:39 AM
I once had the crazy idea of implementing the git http protocol. It's specifications are huge, but if you could finish that, you'd have true git (push,pull,branch,…) and it would work with any online repository manager that supports git. :P/>
As in peripheral (Java) or Lua? o.O
Lua, git supports a protocol purely based on http.

Edit: I think that this document proves me wrong :mellow:/>: http://git-scm.com/b...nsfer-Protocols
It seems that with pure http, you can still only fetch data.

Edit2: Now this documents says you can: http://git-scm.com/book/ch4-1.html
It’s possible to make Git push over HTTP as well, although that technique isn’t as widely used and requires you to set up complex WebDAV requirements. Because it’s rarely used, we won’t cover it in this book. If you’re interested in using the HTTP-push protocols, you can read about preparing a repository for this purpose at http://www.kernel.or...-over-http.txt. One nice thing about making Git push over HTTP is that you can use any WebDAV server, without specific Git features; so, you can use this functionality if your web-hosting provider supports WebDAV for writing updates to your web site.
I knew it had to be possible somehow because I do this with Eclipse… I'm 99% sure that GitHub supports pushing over http.

Edit3: I wasn't sure how WebDAV worked. It seems that it adds extra methods to HTTP, which you can't use from CC. :(/> I recommend you looking further into this, but I have little hope left. You can find the source of the git-http-push program here: https://github.com/git/git/blob/master/http-push.c .
zekesonxx #7
Posted 11 January 2013 - 04:52 AM
I believe WebDav requires PUT and DELETE HTTP methods, which ComputerCraft cannot do.
Orwell #8
Posted 11 January 2013 - 04:56 AM
I believe WebDav requires PUT and DELETE HTTP methods, which ComputerCraft cannot do.
Yeh, I just read up on it. It doesn't seem to add PUT nor DELETE, but 7 others according to the wikipedia page.

I kept editing my post and yours didn't show up. :P/>
zekesonxx #9
Posted 11 January 2013 - 06:13 AM
Simple fact is, we cannot contact GitHub or any other Git service without some kind of proxy website.
theoriginalbit #10
Posted 11 January 2013 - 10:58 AM
- big snip -
so after all that, yay or nay? lol


Simple fact is, we cannot contact GitHub or any other Git service without some kind of proxy website.
Starting to get that idea…



Who wants to write a peripheral :P/>
Orwell #11
Posted 11 January 2013 - 11:30 AM
- big snip -
so after all that, yay or nay? lol


Simple fact is, we cannot contact GitHub or any other Git service without some kind of proxy website.
Starting to get that idea…



Who wants to write a peripheral :P/>
Well, final conclusion, fetching data using proper git is possible over http, pushing data isn't possible using CC.

I'm sure that there is a git library for Java out there, so writing a peripheral for it is piece of cake. I'm short on time though and I don't feel like its worth it. :P/> With that, I mean that the API part is probably a lot less work than creating a fresh instance of MCP, a block and a texture for the peripheral. :P/>

Actually, I have an idea. I'm working on a mod right now (picked it up again after 4 months) that's server side only. It allows to install custom Java-side apis into CC and some commands for general computer control. I think that server owners would be much more tempted to install it, as the clients don't need to. And a git Api is just a sort of thing you wouldn't really install seperately as a peripheral on your server. But if it's part of a server-side only, they might. :)/> Still needs to get permission from Dan200 and Cloudy though, as I poke a lot into the internals of CC. -_-/>

Sorry for the unstructered sentences, it's just not happening today. :P/>
theoriginalbit #12
Posted 11 January 2013 - 11:32 AM
Actually, I have an idea. I'm working on a mod right now (picked it up again after 4 months) that's server side only. It allows to install custom Java-side apis into CC and some commands for general computer control. I think that server owners would be much more tempted to install it, as the clients don't need to. And a git Api is just a sort of thing you wouldn't really install seperately as a peripheral on your server. But if it's part of a server-side only, they might. :)/> Still needs to get permission from Dan200 and Cloudy though, as I poke a lot into the internals of CC. -_-/>
Well if that goes ahead it could be awesome…
zekesonxx #13
Posted 11 January 2013 - 12:31 PM
Who wants to write a peripheral :P/>

It already exists. Check out the Sockets peripheral.
Orwell #14
Posted 11 January 2013 - 12:49 PM
Who wants to write a peripheral :P/>

It already exists. Check out the Sockets peripheral.
I think he was hoping for something less raw :P/>. It is a way to achieve what he wants though. :)/> CCSockets hasn't been ported to the very latest CC version yet, but the creator might if you poke him. ;)/>
zekesonxx #15
Posted 12 January 2013 - 04:02 AM
Really, all you have to do is look up a Sockets HTTP request in PHP, there are hundreds. Just port it over to Lua then. Something like httpsoc.request("url", "method", "postData", "headersToAddOrModify", "httpPostBody")
GravityScore #16
Posted 12 January 2013 - 07:39 AM
Or without the CCSockets peripheral, you could send the information to your own PHP script and have it upload the information to GitHub, but I think you were maybe wanting to do this without having to use/host your own server?
Aichan #17
Posted 12 January 2013 - 08:44 AM
All you have to do is have a script waiting for some informations then sent it to Github, cURL is perfect for what you want to do !
Orwell #18
Posted 12 January 2013 - 09:09 AM
As this is the most obvious solution, I assume it's not what he is looking for. I can't be sure though.
theoriginalbit #19
Posted 12 January 2013 - 11:03 AM
Yeh I didn't want to have to use my own server just to do it…. Don't want people relying on it, and don't want another NDFJay situation. ;)/>
Orwell #20
Posted 12 January 2013 - 11:09 AM
Yeh I didn't want to have to use my own server just to do it…. Don't want people relying on it, and don't want another NDFJay situation. ;)/>
Well, I just managed to recompile and reobfuscate my mod and I confirmed it to run and inject APIs when installing on the server only. It should be a piece of cake to use JGit to cook up a git API. I plan on adding a lua program to my mod that mounts to the CC computers and works like the regular git command line tool. :)/> Need to focus on studying for a while first though. :P/>
theoriginalbit #21
Posted 12 January 2013 - 11:10 AM
Cool :)/>
Eric #22
Posted 13 January 2013 - 11:34 AM
You might find this interesting - you can use just about enough of the github API without headers in either request or response to clone a repository in CC. Unfortunately, the API has quite strict rate-limiting for unauthorized applications.
theoriginalbit #23
Posted 13 January 2013 - 12:38 PM
You might find this interesting - you can use just about enough of the github API without headers in either request or response to clone a repository in CC. Unfortunately, the API has quite strict rate-limiting for unauthorized applications.
Yes I have actually seen that, however the issue I was trying to tackle was Issue posting, unfortunately it can't be done, thank you though