The problem with your script is that though you're sending a POST method, you're adding the data in the URL as though it were a GET. I don't use Air so I can't test it, but here the script you linked modified so that I think it should work. You just needed to change xmlhttp.send(NULL)
to xmlhttp.send(data)
, where data
is the query data you were appending to the gists
URL before (including the file and authentication information).
As a simple example, here's an excerpt from a bash script creating a new gist:
#!/usr/bin/env bash
if [ -z "$(git config github.token)" ]
then echo "warning: no api key found, to add follow instructions on github account page."
else echo "attempting to create a new gist using your github authentication..."; fi
SHA=$((curl http://gist.github.com/gists --include \
--data login=$(git config github.user) \
--data token=$(git config github.token) \
--data action_button=private \
--data 'file_ext[gistfile1]=txt' \
--data 'file_contents[gistfile1]=Hello World, this is an example gist!' \
| perl -e 'for(<>){if(/^Location: https?:\/\/gist.github.com\/([0-9a-f]+)/){print $1}}')2>/dev/null)
echo "New example gist created at https://gist.github.com/$SHA"