[英]Can get album covers but not photos within album (facebook api)
Below is my code: 下面是我的代码:
facebookModule.requestWithGraphPath(
'me/albums', {
fields : 'id,name,cover_photo,count,created_time'
},
'GET',
function(graphResp) {
if(graphResp.success) {
if(graphResp.result) {
var albums = JSON.parse(graphResp.result).data;
//get all album ids.
for(x in albums) {
var albumId = albums[x].id;
//get album covers
//var albumCovers= "https://graph.facebook.com/" + (albums[x].cover_photo || 0) + "/picture?access_token=" + facebookModule.accessToken;
//get photos
var photos = "https://graph.facebook.com/" + (albums[x].cover_photo || 0) + "/photos?access_token=" + facebookModule.accessToken;
console.log(test);
}
}
} else if(graphResp.cancelled) {
alert("User Cancelled");
} else {
Ti.API.debug(graphResp.result);
}
}
);
When I do console.log
I get a list of URLs, which are generated from the graph api. 当我执行
console.log
我会得到一个URL列表,这些URL是从图形api生成的。 However I am returning an empty json object for each of them - hence no photos from that particular album is shown. 但是我为它们每个返回一个空的json对象-因此没有显示该特定相册中的照片。
var photos = "https://graph.facebook.com/" + (albums[x].cover_photo || 0) + "/photos?access_token=" + facebookModule.accessToken;
The graph api call for that album is above. 该相册的图形API调用在上方。
cover_photo
will not give you the url of the cover pic; cover_photo
不会提供封面图片的网址; instead it will give you the id of the cover pic. 相反,它将为您提供封面图片的ID 。 Example
例
So, when you do : \\{cover-_pic}/photos
- this will give you a json, you'll have to fetch the required image from that. 因此,当您执行以下操作时:
\\{cover-_pic}/photos
这将为您提供json,您必须从中获取所需的图像。 Example 例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.