HttpService Question

After HttpService:PostAsync, a new post appears on pastebin. How to get data from this post from another script without a link?

1 Like

How to read post from another script without any links.

when the first script posts something to pastebin

it should also set what it posted in a
https://developer.roblox.com/en-us/api-reference/class/StringValue

then the seconds script can use
https://developer.roblox.com/en-us/api-reference/event/StringValue/Changed
to detect when the first script posted something to read the value that was posted

1 Like

What if the other script is on a different server.

im not sure what kind of data your trying to send but cant you send the data using

https://developer.roblox.com/en-us/api-reference/class/MessagingService

here is how to use MessagingService

@5uphi’s solution works fine if it’s within the same experience (game/server). For this, you’ll need to use a GET request, which would look like this:

local urlOf = "https://pastebin.com/raw/%d"
local pastebinId = ...

local function getPastebinCode()
    local data
    local success, errMessage = pcall(
        function()
            data = HttpService:GetAsync(urlOf:format(pastebindId))
            if #data > 0 then
                data = HttpService:JSONDecode(data)
            end
        end
    )

    if success then
        return data
    end
end

If it worked, mark it as the solution. :+1:

pastebindId is “https://pastebin.com/id”?

And is it possible to read the post knowing only dev_key?
or no. If no your answer will be the solution.

Completely! When you create the post and you store the data in return from the PostAsync request, you’ll be storing the id, I would say to use a Signal to store such thing and use some string pattern to find the numbers within the string, It would be too complicated but something like this could work perfectly fine:

-- post script
local dataInReturn = HttpService:PostAsync(...) -- your request to post a pastebin
Signal:Fire(dataInReturn)

And then…

-- get script
local pastebinUrls = {}
local event = ... -- the signal event

event:Connect(
    function(urlToStore)
        table.insert(pastebinUrls, urlToStore)
    end
)

local function getId(pastebinUrl)
    return string.match(pastebinUrl, "%d+")
end

This is just a bit more complicated example, but this is how I would do it. :+1:

This is not possible, since the script won’t know which script to look at! You could have 6 pastebin but, what script should your program get? That’s why you need the ID as it is the unique identifier for it.

Thanks for the help. You helped solve my problem.

1 Like

And yes, I understand that you can not change the pastebin post.