Lua - 等待 Http 响应

我正在尝试弄清如何将 JSONEncoded 表格上传到 PasteBin。它说我需要通过发送 PostAsync 获取我的开发密钥、用户名和密码,并等待来自 PasteBin 的响应以获得我的登录会话密钥。目前这是我的代码:

h = game:GetService'HttpService'
pasteData = h:UrlEncode(h:JSONEncode(ImgScript))
username = 'USERNAMEHERE'
password = 'PASSWORDHERE'
h:PostAsync(
    'http://pastebin.com/api/api_login.php',
    'api_dev_key=DEVKEYHERE&api_user_name=' .. h:UrlEncode(username) .. '&api_user_password=' .. h:UrlEncode(password),
    2
)

api_user_key = GeneratedUserKeyHere //这是我想要的;我不知道如何等待来自 PasteBin 的响应来获取这个键!
h:PostAsync(
    'http://pastebin.com/api/api_post.php',
    'api_dev_key=' .. api_dev_key .. 'api_option=paste&api_user_key=' .. api_user_key .. '&api_paste_private=1&api_paste_expire_date=N&api_paste_format=lua&api_paste_code=' .. h:UrlEncode(h:JSONEncode(ImgScript)) //ImgScript 是表格,
    2
)
点赞
用户3600300
用户3600300

好的,我弄明白了。 PostAsync 不仅会发送数据,还会接收返回的用户密钥,所以这里是可用的脚本。

h = game:GetService'HttpService'
api_dev_key = '你的 DevKey'
api_paste_code = '你上传内容的文本'
api_paste_private = '1' --0 为公开; 1 为未列出; 2 为私人
api_paste_name = '你发布的名称'
api_paste_expire_date = 'N' --N 为永不过期, 10M 为 10 分钟等等。
api_paste_format = 'lua' --语法高亮
api_user_key = ''
api_paste_name = h:UrlEncode(api_paste_name)
api_paste_code = h:UrlEncode(api_paste_code)
username = '你的用户名'
password = '你的密码'

api_user_key = h:PostAsync(
    'http://pastebin.com/api/api_login.php',
    'api_dev_key=' .. api_dev_key .. '&api_user_name=' .. username .. '&api_user_password=' .. password,
    2
)
print(api_user_key) --别删除!生成用户密钥非常必要!
h:PostAsync(
    'http://pastebin.com/api/api_post.php',
    'api_option=paste&api_user_key=' .. api_user_key .. '&api_paste_private=' .. api_paste_private .. '&api_paste_name=' .. api_paste_name .. '&api_paste_expire_date=' .. api_paste_expire_date .. '&api_paste_format=' .. api_paste_format .. '&api_dev_key=' .. api_dev_key .. '&api_paste_code=' .. api_paste_code,
    2
)
2015-10-01 22:02:30