| 485 | } |
| 486 | |
| 487 | async function getAllAlbums(id, access_token) { |
| 488 | let result = []; |
| 489 | let after = ""; |
| 490 | while (true) { |
| 491 | try { |
| 492 | const res = await fetch( |
| 493 | `https://graph.facebook.com/v20.0/${id}/albums?fields=type,name,count,link,created_time&limit=100&access_token=${access_token}&after=${after}` |
| 494 | ); |
| 495 | const json = await res.json(); |
| 496 | if (json.data) result = result.concat(json.data); |
| 497 | |
| 498 | let nextAfter = json.paging?.cursors?.after; |
| 499 | if (!nextAfter || nextAfter === after) break; |
| 500 | after = nextAfter; |
| 501 | } catch (e) { |
| 502 | break; |
| 503 | } |
| 504 | } |
| 505 | return result; |
| 506 | } |
| 507 | |
| 508 | async function fetchAlbumPhotosFromCursor({ |
| 509 | cursor, |