//native
/**
* Get Media URL
* Retrieve the download URL and metadata of an uploaded or received media item. The URL is only valid for 5 minutes and requires the access token to download.
*/
export async function main(auth: RT.WhatsappBusiness, media_id: string) {
const apiVersion = auth.api_version || "v25.0"
const url = new URL(`https://graph.facebook.com/${apiVersion}/${media_id}`)
url.searchParams.append("phone_number_id", auth.phone_number_id)
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 5 hours ago