我可以从Facebook用户的帐户中获取所有相册。我试图在网格中显示它,但我也需要封面照片的相册。我试过下面的代码:
<ion-grid>
<div *ngFor="let album of albums; let i = index;">
<ion-row *ngIf="i % 3 === 0">
<ion-col col-4 *ngIf="i < albums.length">
<ion-card>
<img src="https://graph.facebook.com/{{albums[i].id}}/picture?type=album" />
<div class="card-title">{{ albums[i].name }}</div>
</ion-card>
</ion-col>
<ion-col col-4 *ngIf="i+1 < albums.length">
<ion-card (click)="albumClicked(album)">
<img src="https://graph.facebook.com/{{albums[i+1].id}}/picture?type=album" />
<div class="card-title">{{ albums[i+1].name }}</div>
</ion-card>
</ion-col>
<ion-col col-4 *ngIf="i+2 < albums.length">
<ion-card (click)="albumClicked(album)">
<img src="https://graph.facebook.com/{{albums[i+2].id}}/picture?type=album" />
<div class="card-title">{{ albums[i+2].name }}</div>
</ion-card>
</ion-col>
</ion-row>
</div>
</ion-grid>
这是我获取相册的方式:
FacebookService.ts:
...
getUserAlbums(userID) {
return this.facebook.api("/v2.9/" + userID + "/albums", []);
}
...
FacebookAlbumsPage.ts:
...
getUserAlbums(facebookUserId) {
this.showLoading();
this.facebookUserDetails.getUserAlbums(facebookUserId).then((res) => {
this.albums = res.data;
this.hideLoading();
});
}
...
获取图像时,我得到以下错误:
Failed to load resource: the server responded with a status of 400 ()
有没有人知道如何使用Ionic2获取封面照片的Facebook专辑?
修改 这是在img src中传递的url:
https://graph.facebook.com/186028675250734/picture?type=album
但是当我直接在浏览器中打开链接时,它返回错误:
{
"error": {
"message": "Unsupported get request. Object with ID '186028675250734' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"fbtrace_id": "BtQDS1csSgu"
}
}