gpt4 book ai didi

ios - Facebook sdk io 从相册中获取照片

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:49:56 24 4
gpt4 key购买 nike

我得到了 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"
}
]

最佳答案

当您将对象添加到您的 arrayAllPhotos 时,使用 source 而不是 id:

[arrayAllPhotos addObject:[NSUrl urlWithString:[anAlbum objectForKey:@"source"]]];

哦,然后当你想使用这些图像时,请执行以下操作:

UIImage *image = [[UIImage imageWithData:[NSData dataWithContentsOfUrl:[arrayAllPhotos objectAtIndex:indexOfObjectYouWant]]]];

希望对你有帮助

关于ios - Facebook sdk io 从相册中获取照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11703307/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com