【问题标题】:iOS Facebook SDK - Retrieve Friends Profile PicturesiOS Facebook SDK - 检索好友个人资料图片
【发布时间】:2012-04-20 11:46:07
【问题描述】:

我正在使用 Facebook iOS SDK 并检索到用户好友列表。 现在我有了每个朋友的姓名和 ID。

我想找回好友头像,可以吗?

谢谢!

【问题讨论】:

    标签: iphone objective-c ios facebook


    【解决方案1】:

    【讨论】:

    • 谢谢,但由于某种原因,我在尝试检索朋友的个人资料图片时收到“空白”个人资料图片,而不是全部...
    • 是否有任何示例/链接可用于在 facebook sa 和 twitter 中获取上传的图片和视频?
    • Facebook(手机上的应用程序和我们对其进行的任何调用)是否不会缓存图像,在这种情况下,如果我们调用它而不是直接发出 HTTP 请求,则查找时间会更短。如果Facebook SDK确实缓存了用户的展示图片,如何访问呢?
    【解决方案2】:

    在 cellForRowAtIndexPath 中,您已经获得了 facebook 用户的 id .....我说得对吗??? 之后,只需使用下面的 url 通过 URLRequest 获取个人资料图片....

     - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if([friends count]!=0)
        {                        
            NSString *strurl = [[NSString alloc] initWithFormat:@"https://graph.facebook.com/%@/picture",[[friends objectAtIndex:indexPath.row] objectForKey:@"id"]];
            NSURL *url=[NSURL URLWithString:strurl];///here you can retrive the image
            [cell setObjItem:url title:[[friends objectAtIndex:indexPath.row] objectForKey:@"name"]];
            // Configure the cell.
        }
        else
        {
            NSLog(@"<<<<<<<<<<------Array Null-------->>>>>>>");
        }
        return cell;
    }
    

    【讨论】:

    • 谢谢,但正如我之前提到的;有时我将朋友的个人资料图片检索为“空白”图片,这意味着只要您没有上传任何个人资料图片,Facebook 提供的浅蓝色背景上的白人剪影
    • 是的,这个 url 获取显示在 facebook 上的 fbuser 的图片,所以如果用户不选择个人资料图片并且它的跳过空白,那么带有浅蓝色背景的 FB 默认图片会出现它的默认图片,由 FB bt 你想要什么? ?
    • 只是一个建议,你正在分配strurl,但没有发布它,考虑也发布它。或者只使用[NSString stringWithFormat]
    【解决方案3】:
     -(void)fbFriends {
            [self.facebook requestWithGraphPath:@"me/friends" andDelegate:self];
        }
        -(void)fbFriendsInfo :(NSString *)profileid {
            [self.facebook requestWithGraphPath:profileid andDelegate:self];
        }
    
    
        - (void)request:(FBRequest *)request didLoad:(id)result{
            [self hideSpinner];
    
            lblGender.text = [result objectForKey:@"gender"];
            lblName.text = [result objectForKey:@"name"];
            self.idi = [result objectForKey:@"id"];
    
            NSString *first_name = [result objectForKey:@"first_name"];
            NSString *gender = [result objectForKey:@"gender"];
            NSString *last_name = [result objectForKey:@"last_name"];
            NSString *link = [result objectForKey:@"link"];
            NSString *name = [result objectForKey:@"name"];
            NSString *updated_time = [result objectForKey:@"updated_time"];
    
            NSLog(@"Profile Info : \n\n%@,\n%@,\n%@,\n%@,\n%@,\n%@,\n%@",first_name,gender,idi,last_name,link,name,updated_time);
    
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:AlertName message:@"Facebook Done." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
            [alert release];
        }
    

    使用共享控制器类并调用fbFriends 这样你会得到朋友的id 然后调用fbFriendsInfo 它会返回你朋友的所有信息。

    【讨论】:

    • 感谢您的回复,我确实有朋友的 id,但问题是当我尝试检索朋友的个人资料图片时,有时我会检索到“空白”个人资料图片,尽管我应该能够访问他的个人资料图片
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-21
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多