@yoonion/mimi-seed-mcp 0.10.2 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/instagram/api.js +20 -0
- package/package.json +1 -1
package/dist/instagram/api.js
CHANGED
|
@@ -66,6 +66,23 @@ export async function fetchUserId(accessToken) {
|
|
|
66
66
|
}
|
|
67
67
|
return id;
|
|
68
68
|
}
|
|
69
|
+
// 이미지/캐러셀 컨테이너는 Meta 서버 처리가 끝난 뒤에만 publish 할 수 있다.
|
|
70
|
+
// 완료 전에 media_publish 를 호출하면 code 9007/2207027 이 반환된다.
|
|
71
|
+
async function waitForContainer(cfg, containerId) {
|
|
72
|
+
const MAX_ATTEMPTS = 20;
|
|
73
|
+
const INTERVAL_MS = 3000; // 최대 ~60초 대기
|
|
74
|
+
for (let i = 0; i < MAX_ATTEMPTS; i++) {
|
|
75
|
+
const { status_code, status } = await igFetch(cfg.accessToken, `/${containerId}`, { fields: 'status_code,status', access_token: cfg.accessToken });
|
|
76
|
+
const current = status_code ?? status;
|
|
77
|
+
if (current === 'FINISHED')
|
|
78
|
+
return;
|
|
79
|
+
if (current === 'ERROR' || current === 'EXPIRED') {
|
|
80
|
+
throw new Error(`Instagram 미디어 처리 실패 (${current}).`);
|
|
81
|
+
}
|
|
82
|
+
await new Promise((resolve) => setTimeout(resolve, INTERVAL_MS));
|
|
83
|
+
}
|
|
84
|
+
throw new Error('Instagram 미디어 처리 대기 시간 초과 (60초). 잠시 후 다시 시도하세요.');
|
|
85
|
+
}
|
|
69
86
|
async function fetchPermalink(cfg, mediaId) {
|
|
70
87
|
try {
|
|
71
88
|
const meta = await igFetch(cfg.accessToken, `/${mediaId}`, { fields: 'permalink', access_token: cfg.accessToken });
|
|
@@ -95,6 +112,8 @@ export async function postCarousel(cfg, imageUrls, caption) {
|
|
|
95
112
|
const child = await igFetch(cfg.accessToken, `/${cfg.userId}/media`, { image_url: url, is_carousel_item: 'true', access_token: cfg.accessToken }, 'POST');
|
|
96
113
|
childIds.push(child.id);
|
|
97
114
|
}
|
|
115
|
+
for (const childId of childIds)
|
|
116
|
+
await waitForContainer(cfg, childId);
|
|
98
117
|
// Step 2: carousel container 생성
|
|
99
118
|
const carousel = await igFetch(cfg.accessToken, `/${cfg.userId}/media`, {
|
|
100
119
|
media_type: 'CAROUSEL',
|
|
@@ -102,6 +121,7 @@ export async function postCarousel(cfg, imageUrls, caption) {
|
|
|
102
121
|
caption,
|
|
103
122
|
access_token: cfg.accessToken,
|
|
104
123
|
}, 'POST');
|
|
124
|
+
await waitForContainer(cfg, carousel.id);
|
|
105
125
|
// Step 3: publish
|
|
106
126
|
const published = await igFetch(cfg.accessToken, `/${cfg.userId}/media_publish`, { creation_id: carousel.id, access_token: cfg.accessToken }, 'POST');
|
|
107
127
|
return {
|
package/package.json
CHANGED