Decode URL
Decodes a URL and retrieves Open Graph (OG) metadata, such as title, image, description, and the URL itself. This function helps in fetching rich previews of URLs by extracting their metadata.
Steps to decode a URL
- Create a DecodeUrlRequest object using the builder pattern.
- Call the
decodeUrl()
function using the instance ofConversationClient
, passing therequest
object and an optional response handler. - Process the response LMResponse<DecodeUrlResponse> to handle the decoded metadata or any errors.
let request = DecodeUrlRequest.builder()
.url("https://example.com")
.build()
LMChatClient.shared.decodeUrl(request: request) { response in
if let result = response?.data {
// Handle success
} else if let error = response?.error {
// Handle error
print("Error decoding URL: \(error.localizedDescription)")
}
}
Models
DecodeUrlRequest
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
url | String | The URL to be decoded |
DecodeUrlResponse
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
ogTags | LinkOGTag | metadata retrieved from the URL |