Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const snapins = async (urlIgPost) => {
- const headers = {
- "content-type": "application/x-www-form-urlencoded",
- }
- const response = await fetch("https://snapins.ai/action.php", {
- headers,
- "body": "url=" + encodeURIComponent(urlIgPost),
- "method": "POST"
- })
- if (!response.ok) throw Error (`gagal mendownload informasi. ${response.status} ${response.statusText}`)
- const json = await response.json() // kamu bisa console.log json ini langsung dan liat objek nya langsung.
- const name = json.data?.[0]?.author?.name || "(no name)"
- const username = json.data?.[0]?.author?.username || "(no username)"
- let images = []
- let videos = []
- json.data.map(v => {
- if (v.type == "image"){
- images.push(v.imageUrl)
- }else if (v.type == "video"){
- videos.push(v.videoUrl)
- }
- })
- return {name, username, images, videos}
- }
- // cara pakek
- snapins("https://www.instagram.com/p/C5VRXlaypRw/")
- .then(console.log)
- .catch(error => console.log(error.message))
Add Comment
Please, Sign In to add comment