### lib functions from carousel ad ## Get Image Hash ``` import axios from 'axios'; import imageToBase64 from 'image-to-base64'; export const getImageHashFromAdAccount = async ({ accessToken, adAccountId, imageUrl, }) => { try { console.log(` ---- generating image-hash from ad account ----`); const bytes = await imageToBase64(imageUrl); // console.log(bytes) const res: any = await axios.post( `https://graph.facebook.com/v12.0/act_${adAccountId}/adimages`, { access_token: accessToken, bytes, } ); console.log( `-------------------------- returning image hash -----------------------------` ); console.log(res?.data?.images?.bytes?.hash); return { success: true, data: { imageHash: res?.data?.images?.bytes?.hash, }, }; } catch (error) { console.log( ` --- an error occurred while getting image hash from ad account ---` ); console.log(error); console.log(error?.response?.data); return { success: false, data: null, }; } }; ``` ## Get Video id ``` export const getVideoIdFromFacebookGraph = async ({ accessToken, adAccountId, videoUrl, }) => { try { console.log(` ---- getting video-id from facebook graph -----`); const request: any = await axios.post( `https://graph.facebook.com/v12.0/act_${adAccountId}/advideos`, { access_token: accessToken, file_url: videoUrl, transport: 'cors', } ); console.log(`----------- uploaded video id ------------`); console.log(request?.data?.id); return { success: true, data: { videoId: request?.data?.id, }, }; } catch (error) { console.log( ` --- an error occurred while getting image hash from ad account ---` ); console.log(error); console.log(error?.response?.data); return { success: false, data: null, }; } }; ```