fix Analyse
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
const INSTAGRAM_TOKEN = process.env.INSTAGRAM_TOKEN;
|
||||
|
||||
export async function getInstagramData(url) {
|
||||
const reelMatch = url.match(/instagram\.com\/(?:p|reel)\/([A-Za-z0-9_-]+)/);
|
||||
const usernameMatch = url.match(/instagram\.com\/([^/]+)\//);
|
||||
|
||||
if (INSTAGRAM_TOKEN) {
|
||||
try {
|
||||
const oembedUrl = `https://graph.facebook.com/v18.0/instagram_oembed?url=${encodeURIComponent(url)}&fields=author_name,thumbnail_url,title,html&access_token=${INSTAGRAM_TOKEN}`;
|
||||
const response = await fetch(oembedUrl);
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
return {
|
||||
title: data.title || '',
|
||||
author: data.author_name || '',
|
||||
authorUrl: `https://www.instagram.com/${data.author_name || ''}`,
|
||||
thumbnail: data.thumbnail_url || '',
|
||||
embedHtml: data.html || '',
|
||||
reelId: reelMatch ? reelMatch[1] : null,
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Instagram oEmbed Fehler:', e.message);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
title: '',
|
||||
author: usernameMatch ? usernameMatch[1] : '',
|
||||
authorUrl: usernameMatch ? `https://www.instagram.com/${usernameMatch[1]}` : '',
|
||||
thumbnail: '',
|
||||
embedHtml: '',
|
||||
reelId: reelMatch ? reelMatch[1] : null,
|
||||
};
|
||||
}
|
||||
|
||||
export function isInstagramUrl(url) {
|
||||
return /instagram\.com\/(p|reel)\//.test(url);
|
||||
}
|
||||
Reference in New Issue
Block a user