我得到了facebook sdk op并且正在运行。我尝试获取专辑的所有照片。目前我正在使用这个:
NSString *S = [[NSString alloc] initWithFormat:@"%s%@%s","https://graph.facebook.com/",albumID, "/photos"];
[facebook requestWithGraphPath:S andDelegate:self];
我也得到了一个结果,我尝试将其解析为一组照片或照片ID。但我试了几个小时,每次都在网上搜索,但我找不到解决办法。我究竟做错了什么?
- (void)request:(FBRequest *)request didLoad:(id)result
for (NSDictionary *anAlbum in [result objectForKey:@"data"]) {
[arrayAllPhotos addObject:[anAlbum objectForKey:@"id"]];
NSString *url = [[NSString alloc] initWithFormat:@"https://graph.facebook.com/%@/picture",[arrayAllPhotos objectAtIndex:counter]];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url]]];
}
}
这是我从Facebook回来的JSON。提前谢谢!
{
"data": [
{
"id": "244119762368747",
"from": {
"name": "Eindhovens Studenten Corps Intro",
"category": "Non-profit organization",
"id": "235447296569327"
},
"picture": "http://photos-g.ak.fbcdn.net/hphotos-ak-snc7/392553_244119762368747_67274374_s.jpg",
"source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s720x720/392553_244119762368747_67274374_n.jpg",
"height": 480,
"width": 720,
"images": [
{
"height": 1365,
"width": 2048,
"source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s2048x2048/392553_244119762368747_67274374_n.jpg"
},
{
"height": 640,
"width": 960,
"source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc7/392553_244119762368747_67274374_n.jpg"
},
{
"height": 480,
"width": 720,
"source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s720x720/392553_244119762368747_67274374_n.jpg"
},
{
"height": 320,
"width": 480,
"source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s480x480/392553_244119762368747_67274374_n.jpg"
},
{
"height": 213,
"width": 320,
"source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s320x320/392553_244119762368747_67274374_n.jpg"
},
{
"height": 120,
"width": 180,
"source": "http://photos-g.ak.fbcdn.net/hphotos-ak-snc7/392553_244119762368747_67274374_a.jpg"
},
{
"height": 86,
"width": 130,
"source": "http://photos-g.ak.fbcdn.net/hphotos-ak-snc7/392553_244119762368747_67274374_s.jpg"
},
{
"height": 86,
"width": 130,
"source": "http://photos-g.ak.fbcdn.net/hphotos-ak-snc7/s75x225/392553_244119762368747_67274374_s.jpg"
}
]
答案 0 :(得分:1)
当您向arrayAllPhotos
使用source
而不是id
添加对象时:
[arrayAllPhotos addObject:[NSUrl urlWithString:[anAlbum objectForKey:@"source"]]];
哦,然后当你想使用这些图像时:
UIImage *image = [[UIImage imageWithData:[NSData dataWithContentsOfUrl:[arrayAllPhotos objectAtIndex:indexOfObjectYouWant]]]];
希望有所帮助