首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Lua -上传到Pastebin

Lua -上传到Pastebin
EN

Stack Overflow用户
提问于 2015-09-23 20:29:33
回答 2查看 2K关注 0票数 1

请注意,这是Roblox版本的lua。我想上传一张桌子给巴斯丁。这是我给巴斯丁的东西。

代码语言:javascript
复制
h = game:GetService'HttpService'
JSON = h:JSONEncode(ImgScript) --ImgScript is a table formatted like {{x,y,z}, {x,y,z}, {x,y,z}, etc.}
h:PostAsync('http://pastebin.com/api/api_post.php','&api_dev_key=CensoredDevKey&api_option=paste&api_paste_code=' .. JSON)

这不管用,我似乎也搞不懂原因。

编辑:我也尝试过这个,但没有成功。

代码语言:javascript
复制
h = game:GetService'HttpService'
api_params = {
    ["api_dev_key"] = "CensoredDevKey",
    ["api_option"] = "paste",
    ["api_paste_code"] = ImgScript
}
api_params = h:JSONEncode(api_params)
h:PostAsync('http://www.pastebin.com/api/api_post.php', api_params)

编辑:我也尝试过这样做,但没有奏效:

代码语言:javascript
复制
h = game:GetService'HttpService'
JSON = h:JSONEncode(ImgScript) --ImgScript is a table formatted like {{x,y,z}, {x,y,z}, {x,y,z}, etc.}
data = h:UrlEncode('&api_dev_key=CensoredDevKey&api_option=paste&api_paste_code=' .. JSON)
h:PostAsync('http://pastebin.com/api/api_post.php', data)
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-10-25 18:37:52

因此,我已经完成了代码,但遗憾的是,Roblox将PostAsync大小限制为256个字节,因此任何大于该大小的上传都将是GZIPed (高达1024 do ),Pastebin不知道该如何处理。

无论如何,我已经在这里发布了代码:http://www.roblox.com/Pastebin-Upload-item?id=302297532

它是:

代码语言:javascript
复制
--Created by GShocked. PM me if you have questions!

h = game:GetService'HttpService'
api_dev_key = '' --Your Pastebin developer key goes here. Log in first, and then you can find it at pastebin.com/api
api_paste_code = '' --The content of your new paste
api_paste_private = '1' --0 public; 1 unlisted; 2 private
api_paste_name = '' --Name your new paste
api_paste_expire_date = 'N' --N for never expire, 10M for 10 minutes, etc.
api_paste_format = 'lua' --The syntax highlighting
api_user_key = '' --This is generated using the login info
api_paste_name = h:UrlEncode(api_paste_name)
api_paste_code = h:UrlEncode(api_paste_code)
username = '' --Your Pastebin username goes here
password = '' --Your Pastebin password goes here

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
)
票数 0
EN

Stack Overflow用户

发布于 2015-09-24 06:26:08

尝试以下几点:

代码语言:javascript
复制
h = game:GetService'HttpService'
pasteData = h:UrlEncode( h:JSONEncode(ImgScript) )
h:PostAsync(
    'http://pastebin.com/api/api_post.php',
    'api_dev_key=CensoredDevKey&api_option=paste&api_paste_code=' .. pasteData,
    2
)

最后一个参数2 指定正在发送的数据是Application/Url-Encoded

我认为这应该能起作用。如果没有,一定要通知这里。

PS:你从哪里收到这个邮件请求的结果?

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32748891

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档