开发者

Using a UIImageView to show a random facebook profile picture

开发者 https://www.devze.com 2023-04-03 02:48 出处:网络
I have a very simple UIImageView that I can get to show a profile picture from facebook (code shown below). To get the URL of the picture I just go to anyones profile (doesnt matter if youre logged in

I have a very simple UIImageView that I can get to show a profile picture from facebook (code shown below). To get the URL of the picture I just go to anyones profile (doesnt matter if youre logged in, got them as a friend etc), right click on their profile picture and select 'copy image address' and pasted it into the code. I know you can also get the picture by changing the picture url for this http://graph.facebook.com/harryhall1/picture?type=large, either works fine.

Now, my qu开发者_运维百科estion is can I get this to generate a profile picture from a random profile? In my mind this should be possible because I do not have to be logged in to facebook etc to view any random persons profile picture, I can right click on their profile picture and save it, copy the url etc, etc. I'm just not sure how to get a random profile id. I really would appreciate any help on this guys.

@interface NextImageViewController : UIViewController {

    IBOutlet UIImageView *imageView;
    NSInteger imageCount;
    NSArray *imageArray;
}

- (IBAction) nextImagePush;

@end

@implementation NextImageViewController

- (IBAction) nextImagePush {

    UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://profile.ak.fbcdn.net/hprofile-ak-snc4/211479_517418990_3896134_n.jpg"]]];
    [imageView setImage:img];
    imageCount++;
}


Try using info from Facebook's Graph API. You don't have to be authorized or anything to get basic profile info. Data is returned in JSON format, like this - http://graph.facebook.com/?id=dunenkoff. You can supply numerical user id's into id query argument.

More info on Graph API here - http://developers.facebook.com/docs/reference/api/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号