我已经通过网络搜索了所有,并下载了Facebook SDK的东西来尝试上传照片功能,它在那里工作。 完全相同的代码到我的应用程序,它不起作用。 请帮忙? 这是我的代码:Facebook图形API上传照片问题
- (IBAction)pushUpload:(id)sender {
NSString *path = @"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, @"picture",
nil];
[_facebook requestWithGraphPath:@"me/photos"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
[img release];
[loadingIcon startAnimating];
}
正如你可以看到我已经放在那里loadingIcon启动动画时,其上载..,并在请求didload我做的stopanimating命令时,它已经成功上传。
-(void)request:(FBRequest *)request didLoad:(id)result{
[loadingIcon stopAnimating];
if ([result isKindOfClass:[NSArray class]]) {
result = [result objectAtIndex:0];
}
if ([result objectForKey:@"owner"]) {
[loadingIcon stopAnimating];
UIAlertView *alert;
alert = [[UIAlertView alloc] initWithTitle:@""
message:@"Photo uploaded."
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
[alert release];
} else {
// [self.label setText:[result objectForKey:@"name"]];
}
}
事情是,加载图标只是保持动画,没有错误,但仍然没有图片上传到我的Facebook帐户。任何想法为什么?
这是我的.h文件中的代码:
@interface UploadPhotosViewController: 的UIViewController(FBRequestDelegate,FBDialogDelegate, FBSessionDelegate){
IBOutlet UIImageView *imageView; IBOutlet UIActivityIndicatorView *loadingIcon; IBOutlet UIBarButtonItem *_pushPick; IBOutlet UIBarButtonItem *_pushUpload; Facebook * _facebook; }
@属性(只读)Facebook的Facebook的* ;
- (IBAction)pushUpload:(id)sender;
- (IBAction)pushPick:(id)sender;
// UINavigationControllerDelegate,UIImagePickerControllerDelegate,
@end
另外一点需要注意的是,目前的(FBRequestDelegate,FBDialogDelegate,FBSessionDelegate)无颜色指示灯,当有应该是.. 这是个问题吗?
嗨,感谢您的回复,但不幸的是,它仍然不适用于您的代码...>< – user891526