我試圖在Facebook上發佈圖片,但沒有成功呢,我 代碼:如何通過iPhone應用程序在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];
}
但它沒有公佈。
在這裏看到我的答案http://stackoverflow.com/questions/750328/documented-process-for-using-face-book-connect-for-the-iphone-to-upload-photos/6506549#6506549它使用圖形Api上傳照片。 – 2011-06-28 13:05:33