Lua - 等待 Http 响应
Lua - Waiting for Http Response
注意:这是 Roblox 的 Lua 版本。
我正在研究如何将 JSONEncoded table 上传到 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 --THIS is what I am after; I don't know how to wait for a response from Pastebin to get this key!
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 is the table,
2
)
好的,我明白了。
PostAsync 不仅发送数据,还接收返回的用户密钥,所以这里是工作脚本。
h = game:GetService'HttpService'
api_dev_key = 'YourDevKeyHere'
api_paste_code = 'The text of your upload content here'
api_paste_private = '1' --0 public; 1 unlisted; 2 private
api_paste_name = 'The name of your paste here'
api_paste_expire_date = 'N' --N for never, 10M for 10 minutes, etc.
api_paste_format = 'lua' --The syntax highlighting
api_user_key = ''
api_paste_name = h:UrlEncode(api_paste_name)
api_paste_code = h:UrlEncode(api_paste_code)
username = 'YourUsernameHere'
password = 'YourPasswordHere'
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) --DON'T DELETE THIS! IT IS ESSENTIAL FOR THE USER KEY TO BE GENERATED!
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
)
注意:这是 Roblox 的 Lua 版本。
我正在研究如何将 JSONEncoded table 上传到 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 --THIS is what I am after; I don't know how to wait for a response from Pastebin to get this key!
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 is the table,
2
)
好的,我明白了。 PostAsync 不仅发送数据,还接收返回的用户密钥,所以这里是工作脚本。
h = game:GetService'HttpService'
api_dev_key = 'YourDevKeyHere'
api_paste_code = 'The text of your upload content here'
api_paste_private = '1' --0 public; 1 unlisted; 2 private
api_paste_name = 'The name of your paste here'
api_paste_expire_date = 'N' --N for never, 10M for 10 minutes, etc.
api_paste_format = 'lua' --The syntax highlighting
api_user_key = ''
api_paste_name = h:UrlEncode(api_paste_name)
api_paste_code = h:UrlEncode(api_paste_code)
username = 'YourUsernameHere'
password = 'YourPasswordHere'
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) --DON'T DELETE THIS! IT IS ESSENTIAL FOR THE USER KEY TO BE GENERATED!
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
)