iOS facebook sdk如何下载相册,个人资料照片数据 [英] iOS facebook sdk how to download album, profile photos data

查看:155
本文介绍了iOS facebook sdk如何下载相册,个人资料照片数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想允许我的iPhone应用程序用户从他们的Facebook个人资料照片中查看和选择,下载照片以用作个人资料图片。我正在使用Facebook SSO SDK并成功登录并访问图形信息。尝试使用

  [facebook requestWithGraphPath:@me / albums]访问照片信息(SSO登录成功后) 

但我只是得到一个空数据对象作为回报。我尝试使用 Facebook API资源管理器,这是非常有帮助的,它给了我/图片和/照片和/相册的数据。由于某些原因,我没有使用requestWithGraphPath与我/专辑,我/图片或我/照片获得相同的数据。只是简单的我工作正常,但没有给我任何图片信息。有人可以告诉我我在做错什么?



注意:这是API参考: Facebook Graph API



我的照片配置文件的工作原理如下:

  [facebook requestWithGraphPath:@me?fields = picture]; 

更新:真的我想要所有的个人资料照片,这是一张相册,所以我需要知道如何通过iOS访问相册。我已经成功获得了个人资料图片。



我根据API为相册添加了user_photos和friends_photos的权限:

  NSArray * permissions = [[NSArray alloc] initWithObjects:
@user_likes,
@user_birthday,
@ email,
@publish_stream,
@publish_actions,
@user_photos,
@friends_photos,
nil];
[facebook authorize:permissions];

当我说我得到空数据时,这是JSON结果(请求中:didLoad: )返回:

  {
data =(
);
}

从我的日志文件输出:



pre> - (void)请求:(FBRequest *)请求didLoad:(id)result {
NSLog(@%@,result);

}

最后注意:最后的工作是使用另一台设备,这更新了我的权限,然后一切都开始工作!我最好的猜测是,模拟器和我的iPhone没有更新我的Facebook权限,所以我被拒绝访问照片和获取一个空数据。



这个问题是一个很大的帮助:如何在iPhone SDK中获取Facebook相册的照片

解决方案

为了未来的观众,我将答案提交给我自己的问题,因为我还没有收到任何其他人的完整答复。



首先,您必须具有正确的权限,user_photosfriends_photos。那么你必须确保测试设备更新您的权限 - 我认为重新启动设备是最终对我而言。



一旦你这样做,您可以通过SSO登录使用此电话获取相册的JSON列表:

  [facebook requestWithGraphPath:@我/ albumsandDelegate:self]; 

这将给出JSON数组(在密钥数据),其中包含每张专辑的各种信息,包括ID。要获得特定相册ID的照片列表(例如123456789),请执行以下操作:

  NSString * albumId = @ 123456789; 
NSString * path = [NSString stringWithFormat:@%@ / photos,albumId];
[facebook requestWithGraphPath:path andDelegate:self];

您的回复当然会通过 FBRequestDelegate 方法请求:didLoad 可以处理JSON数据。


I would like to allow my iPhone App users to view and select from their facebook profile photos, download the photo to use as a profile pic. I am currently using the Facebook SSO SDK and successfully logging in and accessing Graph information. Have tried to access photo information (after successful SSO login) using

[facebook requestWithGraphPath:@"me/albums"];

but I just get an empty data object in return. I've tried using the Facebook API explorer, which is very helpful, and it does give me data for /picture and /photos and /albums. For some reason I don't get the same data using requestWithGraphPath with me/albums, me/picture or me/photos. Just plain "me" works fine but doesn't give me any picture info. Can anybody tell me what I'm doing wrong?

Note: this is the API reference: Facebook Graph API

I did get picture profile to work like this:

[facebook requestWithGraphPath:@"me?fields=picture"];

Update: really I want all of the Profile Photos which is a photo album so I need to know how to access albums through iOS. The profile picture I have successfully obtained now.

I have added permissions "user_photos" and "friends_photos" for photo albums according to API:

    NSArray *permissions = [[NSArray alloc] initWithObjects:
                            @"user_likes",
                            @"user_birthday",
                            @"email",
                            @"publish_stream",
                            @"publish_actions",
                            @"user_photos",
                            @"friends_photos",
                            nil];
    [facebook authorize:permissions];

When I say I'm getting empty data, this is the JSON result (in request:didLoad:) that gets returned:

 {
    data =     (
    );
}

From my log file output:

- (void) request:(FBRequest *)request didLoad:(id)result{
    NSLog(@"%@",result);

}

Final Note: What finally worked was to use another device, which updated my permissions and then everything started working! My best guess is that the emulator and my iPhone were not updating my facebook permissions so I was being denied access to photos and getting an empty data array.

This SO question was a big help also: How to get photos of a facebook album in iPhone SDK?

解决方案

For the sake of future viewers, I'm putting the answer to my own question since I haven't received a complete answer from anyone else.

First, you must have the right permissions, either "user_photos" or "friends_photos". Then you have to make sure that your test device updates your permissions -- I think restarting the device is what ultimately did it for me.

Once you've done that, you can get the JSON list of albums, after logging in via SSO, using this call:

[facebook requestWithGraphPath:@"me/albums" andDelegate:self];

This will give JSON array (under key data) with all kinds of information about each album, including the ID. To get a list of photos for a particular album ID (say its '123456789') do the following:

NSString * albumId = @"123456789";
NSString * path = [NSString stringWithFormat:@"%@/photos", albumId];
[facebook requestWithGraphPath:path andDelegate:self];

Your response will of course come via the FBRequestDelegate method request:didLoad where you can process the JSON data.

这篇关于iOS facebook sdk如何下载相册,个人资料照片数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆