Created
January 26, 2017 15:05
-
-
Save tmplinshi/6e57d1391031eeea53218bb47ac8e462 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CreateGist(content, description:="", filename:="file1.ahk", token:="", public:=true) { | |
url := "https://api.github.com/gists" | |
obj := { "description": description | |
, "public": (public ? "true" : "false") | |
, "files": { (filename): {"content": content} } } | |
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1") | |
whr.Open("POST", url) | |
whr.SetRequestHeader("Content-Type", "application/json; charset=utf-8") | |
if token { | |
whr.SetRequestHeader("Authorization", "token " token) | |
} | |
whr.Send( JSON_FromObj(obj) ) | |
if retUrl := JSON_ToObj(whr.ResponseText).html_url | |
return retUrl | |
else | |
throw, whr.ResponseText | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment