iphone - How to Add Image when creating Event using Facebook IOS SDK

I have the following code to add an event everything works and loads to facebook with no problems the only problem is that the image does not upload nor is there any type of help with this in the docs for iOS maybe im looking in the wrong place? Maybe you have been through this and can help. Thank you

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                 [delegate facebook].accessToken, @"access_token",
                                 @"Going To Eat!", @"name",
                                 @"description of the event", @"description",
                                 @"2012-08-20T17:00:00+0000", @"start_time",
                                 @"2012-08-21T17:00:00+0000", @"end_time",
                                 @"Carlsbad", @"city",
                                 @"CA", @"state",
                                 @"900 safe street", @"street",
                                 @"OPEN", @"privacy",
                                 @"https://.../img/faces/pizza-port-brewing-carlsbad.jpg", @"@file.jpg",
                                 nil];

  [[delegate facebook] requestWithGraphPath:@"me/events" 
                        andParams:params
                    andHttpMethod:@"POST"
                      andDelegate:self];

Answers


Ok I figured this out if you are using the current Facebook API for IOS then you can pass a UIImage object to the requestWithGraphPath: call it will auto detect it and upload it to your event icon. If its an image link then make a UIImage out of NSURL.

UIImage *image = [[UIImage alloc]initWithImageNamed@"test.png"];    
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                 [delegate facebook].accessToken, @"access_token",
                                 @"Going To Eat!", @"name",
                                 @"description of the event", @"description",
                                 @"2012-08-20T17:00:00+0000", @"start_time",
                                 @"2012-08-21T17:00:00+0000", @"end_time",
                                 @"Carlsbad", @"city",
                                 @"CA", @"state",
                                 @"900 safe street", @"street",
                                 @"OPEN", @"privacy",
                                 image, @"picture",
                                 nil];

  [[delegate facebook] requestWithGraphPath:@"me/events" 
                        andParams:params
                    andHttpMethod:@"POST"
                      andDelegate:self];

please check the document of facebook developer https://developers.facebook.com/docs/reference/api/event/ here. In which you can find parameter "picture" that contain image


Need Your Help