我想在Facebook上发布图片但尚未成功, 我的代码是:
- (void)postToWall{
int im = 1;
NSData *myimgData;
myimgData = [NSData dataWithContentsOfFile:saveImagePath];
//pstimg = myimgData;
NSArray *chunks = [pstimg componentsSeparatedByString: @"."];
NSString *atch= [chunks objectAtIndex: 0];
NSString *filePath = [[NSBundle mainBundle] pathForResource:atch ofType:@"jpg"];
img = [[UIImage alloc] initWithContentsOfFile:filePath];
//start
FBDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
NSString *str = @"Hello";
str = [str stringByReplacingOccurrencesOfString:@" " withString:@"+"];
dialog.cMessage=str;
dialog.userMessagePrompt = @"Enter your message:";
[dialog show];
NSData * findata;
//edited from here
if(im==1)
{
findata = myimgData;
}
else
{
findata = (NSData *)img;
}
NSMutableDictionary * param = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, @"picture",
nil];
FBRequest *uploadPhotoRequest =[FBRequest requestWithDelegate:self] ;
[uploadPhotoRequest call:@"facebook.photos.upload" params:param dataParam:myimgData];
[img release];
}
但它没有发布。
答案 0 :(得分:1)
要在Facebook上发布照片,您需要使用Facebook的iOS SDK:
https://github.com/facebook/facebook-ios-sdk
在那里,您可以找到带有身份验证的示例应用,还有更多内容,例如发布照片。