Skip to content

Instantly share code, notes, and snippets.

@Arahnoid
Forked from maestrith/gist.ahk
Created August 12, 2013 22:37
Show Gist options
  • Save Arahnoid/6215990 to your computer and use it in GitHub Desktop.
Save Arahnoid/6215990 to your computer and use it in GitHub Desktop.
testing
access_token:="" ;Your Github access token goes here if you want to publish it to your Gist list
info:="Code to post goes here" ;Change this to create the new text for the Gist
filename:="mygit.txt" ;change this to whatever you want your file name to be
desc:="my description" ;This is where you would have a description for your Gist
post_gist(info,access_token,filename,desc)
return
post_gist(info,access_token,filename,desc)
{
info:=RegExReplace(info,"([" Chr(34) "\\])","\$1")
for a,b in {"`n":"\n","`t":"\t","`r":""}
StringReplace,info,info,%a%,%b%,All
http:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
json=
(
{"description":"%desc%","public":true,"files":{"%filename%":{"content":"%info%"}}}
)
http.Open("POST","https://api.github.com/gists")
if access_token
http.SetRequestHeader("Authorization","Bearer " access_token)
http.send(json)
codes:=http.ResponseText
RegExMatch(codes,"U)html_url" Chr(34) ":" Chr(34) "(.*)" chr(34),found)
clipboard:=RegExReplace(found1,"\\")
if found1
MsgBox,URL Coppied to clipboard
else
MsgBox,Something went wrong. Here is what the server sent back`n`n%codes%
run, % url
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment