我是 iPhone 应用程序开发新手,我正在尝试通过我们的 iPhone 应用程序在 Facebook 上上传图像。我已经尝试了以下使用 fbconnect 的代码,但它不起作用。
NSMutableDictionary *args = [[[NSMutableDictionary alloc] init] autorelease];
[args setObject:fbimages forKey:@"image"]; // 'fbimages'(it is having 2 images) is an array of 'UIImage' objects..
FBRequest *uploadPhotoRequest = [[[FBRequest alloc] init] autorelease];
uploadPhotoRequest = [FBRequest requestWithDelegate:self];
[uploadPhotoRequest call:@"facebook.photos.upload" params:args];
//[[FBRequest requestWithDelegate:self] call:@"facebook.photos.upload" params:args];
NSLog(@"uploading image is successful");
最佳答案
最后我找到了从 iPhone 上传图片到 facebook 的解决方案。使用下面的代码。它肯定会起作用。
- (void)uploadPhoto{
NSMutableDictionary *args = [[NSMutableDictionary alloc] init];
UIImage *img = [UIImage imageNamed:@"picture1.jpg"];
NSData *data = UIImageJPEGRepresentation(img, 10);
//NSData *data = UIImagePNGRepresentation(img);
NSString *imgstr = [data base64Encoding];
//NSString *imgstr = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
//[args setObject:[UIImage imageNamed:@"antartica1.png"] forKey:@"image"];
[args setObject:imgstr forKey:@"image"]; // 'images' is an array of 'UIImage' objects
uploadimgrequest = [FBRequest requestWithDelegate:self];
[uploadimgrequest call:@"photos.upload" params:args dataParam:data];
//[uploadimgrequest call:@"photos.upload" params:args];
}
获取此代码!!!!!
YUVARAJ.M
关于iphone - 在 Facebook 连接 iphone 上上传图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5164564/