你能告诉我如何使用graph api来获取照片的源url吗?因为我有照片 ID,而且似乎我应该能够拨打电话以获取源网址。
作为我正在尝试做的一个示例,以下代码有效:
-(IBAction)showPicture:(UIButton *)sender;
{
//code to retrieve picture
id path = @"http://photos-e.ak.fbcdn.net/photos-ak-snc1/v5041/89/51/40796308305/a40796308305_1960517_6704612.jpg";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
[self.label setText: (NSString *)path];
imageView.image = img;
[img release];
}
但是,当我有源网址时,它会起作用。有没有办法使用图形 api,这样我就可以id path = @"http://..."
代替id path = [_facebook requestWithGraphPath:@"98423808305/source" andDelegate:self];
???
更新为包括请求 didLoad 方法
- (void)request:(FBRequest *)request didLoad:(id)result {
if ([request.params objectForKey:@"picture"]) {
// Get photo ID from result
NSString *photoId = (NSString *)[result objectForKey:@"id"];
shitStorm = photoId;
}
if ([result isKindOfClass:[NSArray class]]) {
result = [result objectAtIndex:0];
}
if ([result objectForKey:@"owner"]) {
[self.label setText:@"Photo upload Success"];
} else {
[self.label setText:[result objectForKey:@"name"]];
}
};