MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / fetchAlbumPhotosFromCursor

Function fetchAlbumPhotosFromCursor

scripts/test.js:508–536  ·  view source on GitHub ↗
({
          cursor,
          albumId,
          access_token,
        })

Source from the content-addressed store, hash-verified

506 }
507
508 async function fetchAlbumPhotosFromCursor({
509 cursor,
510 albumId,
511 access_token,
512 }) {
513 for (let _ of [
514 `https://graph.facebook.com/v20.0/${albumId}/photos?fields=largest_image{source}&limit=100&access_token=${access_token}`,
515 // `https://graph.facebook.com/v20.0/${albumId}?fields=photos{largest_image{source}}&limit=25&access_token=${access_token}`,
516 ]) {
517 let url = encodeURI(_);
518 if (cursor) url += `&after=${cursor}`;
519 console.log(url);
520 const res = await fetch(url);
521 const json = await res.json();
522 console.log("json", json);
523 const root = json?.photos || json;
524 if (!json || !root?.data?.length) {
525 continue;
526 }
527 return {
528 imgData:
529 root?.data?.map((_) => ({
530 id: _.id,
531 url: _.largest_image.source,
532 })) || [],
533 nextCursor: root?.paging?.cursors?.after || null,
534 };
535 }
536 }
537 async function fetchAlbumPhotos({
538 albumId,
539 access_token,

Callers 1

fetchAlbumPhotosFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected