gpt4 book ai didi

iphone - 未通过 Graph API 接收 Facebook 图片

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:22:13 25 4
gpt4 key购买 nike

我似乎无法使用当前的 iOS 图形方法正确检索用户的个人资料图片。

我的调用:self.pictureRequest = [facebook requestWithGraphPath:@"me/picture"andDelegate:self];

我对结果做了什么:

-(void)request:(FBRequest *)request didLoad:(id)result{
if(request == self.pictureRequest){
UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
image.image = [UIImage imageWithData:result];
[self.view addSubview:image];
NSLog("result is %@", result);
}

所以我现在只想获取个人资料照片。结果在控制台中显示为 null。我想这意味着我实际上没有得到结果? (我尝试了 if(result) NSLog(@"got a result") 但它没有返回,所以我猜 fb 没有发回结果?)

有什么想法吗?我也在这里查找了类似的问题,但不确定它们有什么不同: Problem getting Facebook pictures via iOS

最佳答案

好吧,我可以像这样检索用户照片和其他信息..试试吧

- (void)fetchUserDetails {
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"SELECT uid, name, pic, email FROM user WHERE uid=me()", @"query",nil];

[fb requestWithMethodName:@"fql.query"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];


}//Call this function after the facebook didlogin

并在请求 didLoad 中:

- (void)request:(FBRequest *)request didLoad:(id)result 
{

if([request.url rangeOfString:@"fql.query"].location !=NSNotFound)
{
if ([result isKindOfClass:[NSArray class]] && [result count]>0) {
result = [result objectAtIndex:0];
}
if ([result objectForKey:@"name"]) {

self.fbUserName = [result objectForKey:@"name"];

// Get the profile image
UIImage *fbimage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[result objectForKey:@"pic"]]]];
}

关于iphone - 未通过 Graph API 接收 Facebook 图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10410110/

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