Is there a way to get the thumbnail of a game link or the preview image of a link as if you just posted the link on Discord?
I am attempting to place this inside an embed object that I will use for a Discord webhook.
Here’s an example where the thumbnail for the game is shown along with information about it, I am trying to get that thumbnail image with any given game place link.
Particularly, I am trying to do a webhook request from a Roblox game in Lua. Is there some way to fetch the meta tags of the HTML of the page in my code? I have never done anything like going inside page HTMLs before so any explanation will be helpful.
I assume I’d have to use the content URL correlated to the property “og:image” as my image url?
I’ve attempted this with a trust check failure which I guess means I’ll have to use a proxy link. Any way you can elaborate how to use the Get request to find my image preview metatag? I am not sure of any proxies to use and I am fairly new to this stuff.
You send a get request using the proxy with your URL and parse the response. The response will be a big HTML response.
Here is a function that takes in an HTML response and parses it:
local TagTypes = {
"site_name",
"title",
"type",
"url",
"description"
}
local function GetOGTags(Response)
local Tags = {}
for i, TagName in pairs(TagTypes) do
local LookupString = "<meta property=\"og:" .. TagName .. "\" content=\"(.-)\""
local TagValue = Response:match(LookupString)
print(TagName, TagValue)
if (TagValue) then
Tags[TagName] = TagValue
end
end
return Tags
end
@Rare_tendo I’m having a Trust check error every time I try to use the request URL
@SwagMasterAndrew Without parsing, it will just give me a huge amount of metatags and even the contents of the page like the site’s explanation of their proxy. When parsing, there is an error saying “Can’t parse JSON”. (EDIT: My mistake, I was trying to parse in JSON)
local HTTPService = game:GetService("HttpService")
local TagTypes = {
"site_name",
"title",
"type",
"url",
"description",
"image"
}
local function GetOGTags(Response)
local Tags = {}
for i, TagName in pairs(TagTypes) do
local LookupString = "<meta property=\"?og:" .. TagName .. "\"? content=\"?(.-)\"?>"
local TagValue = Response:match(LookupString)
if (TagValue) then
Tags[TagName] = TagValue
end
end
return Tags
end
local Response = HTTPService:GetAsync("https://moralsharpsearch.dogeconnoisseur.repl.co/?Input=https://www.roblox.com/games/5757755338/SwagMasterAndrews-Place-Number-724")
local Tags = GetOGTags(Response)
for TagName, TagValue in pairs(Tags) do
print(TagName, TagValue)
end