Facebook Graph Api呼叫不适用于iOS [英] Facebook Graph Api call not working for iOS

查看:66
本文介绍了Facebook Graph Api呼叫不适用于iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于iOS应用,使用facebook sdk,我需要从用户相册中获取照片,但是我需要在单个请求中获取它们,以便我可以同时获取有关相册和包含照片的信息,为此我尝试了

For an iOS app, using facebook sdk i need to fetch photos from user's album but i need to fetch them in a single request so that i could get info about albums and containing photos at the same time, for that i tried

/me/albums?fields=count,name,photos.limit(10){images}

该api调用在Graph api资源管理器中运行正常,但在iOS平台上无法正常运行.我只需要照片的图像字段,这就是为什么使用 上面的api调用

that api call is working fine in Graph api explorer but not on iOS platform. I only need images field of photos that is why using above api call

如果我运行此api,它将正常运行

If i run this api it runs fine

/me/albums?fields=count,name,photos.limit(10)

{images} 部分引起了问题,我收到的错误消息是不支持的url,已获得 user_photos

only {images} part is causing the problem, the error message which i get is of unsupported url, have acquired the permissions for user_photos

代码:

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/me/albums?fields=count,name,photos.limit(10){images}" parameters:nil HTTPMethod:@"GET"];
    FBSDKGraphRequestConnection *connection = [[FBSDKGraphRequestConnection alloc] init];
    [connection addRequest:request completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

        if(!error) {
            NSLog(@"result %@",result);
        } else {
            NSLog(@"error description : %@",error.description);
        }
    }];

    [connection start];

推荐答案

我正在通过从图api浏览器侧窗格中添加/删除字段来进行最终的url调用,它正在生成的请求调用是

I was making the final url call by adding/removing fields from graph api explorer side pane, the request call it was generating was

/me/albums?fields=count,name,photos.limit(10){images}

不适用于iOS平台,但是如果我改用这种语法

not working on iOS platform, but if i use this syntax instead

/me/albums?fields=count,name,photos.limit(10).fields(images)

解决照片的字段,然后效果很好,从

to address fields of photos then it works fine, got the inspiration from answer posted here

这篇关于Facebook Graph Api呼叫不适用于iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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