Ben*_*ock 11 javascript air api github
我正在Adobe Air制作一个小应用程序,我需要与Github Gist API进行交互.但是我有点卡住了.
如果您不熟悉Adobe Air,您仍然可以提供帮助,XMLHttpRequest
javascript对象可以执行跨域请求,因为没有这样的域.所以这里没有Adobe Air的具体内容.
在我被困的地方,我想我需要对自己进行身份验证然后进行POST.我只是不明白
小智 4
您的脚本的问题在于,虽然您发送的是 POST 方法,但您却将数据添加到 URL 中,就好像它是 GET 一样。您只需更改xmlhttp.send(NULL)
为xmlhttp.send(data)
,其中data
是您之前附加到gists
URL 的查询数据(包括文件和身份验证信息)。
作为一个简单的示例,以下是创建新要点的bash 脚本的摘录:
#!/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 https://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"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3552 次 |
最近记录: |