2

I am trying to post an OpenGraph story to Facebook on iOS. I have been following this tutorial.

https://developers.facebook.com/docs/ios/open-graph/

I have also been refering to

https://github.com/fbsamples/ios-howtos/blob/master/FBOGSampleSD/FBOGSampleSD/OGShareViewController.m

I am able to get the post to upload to FB but the image is missing. I have tried several variations but have been finding the documentation to be sparse. Any insights would be appreciated:

UIImage *loadedImage = [UIImage imageWithContentsOfFile:file];

NSArray* image = @[@{@"url":loadedImage, @"user_generated": @"true"}];


id<FBGraphObject> objectname =
[FBGraphObject openGraphObjectForPostWithType:@"namespacename:objectname"
                                        title:@"objectname"
                                        image:nil
                                          url:nil
                                  description:@"description"];

id<FBOpenGraphAction> actionname = (id<FBOpenGraphAction>)[FBGraphObject graphObject];

[actionname setObject:image forKey:@"image"];
[actionname setObject:objectname forKey:@"objectname"];


// Check if the Facebook app is installed and we can present the share dialog
FBOpenGraphActionParams *params = [[FBOpenGraphActionParams alloc] init];
params.action = actionname;
params.actionType = @"namespacename:objectname";

// If the Facebook app is installed and we can present the share dialog
if ([FBDialogs canPresentShareDialogWithOpenGraphActionParams:params]) {

     [FBDialogs presentShareDialogWithOpenGraphAction:actionname
                                            actionType:@"namespacename:actionname"
                                 previewPropertyName:@"objectname"
                                               handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
                                                 if(error) {
                                                     // There was an error
                                                        NSLog(@"Error publishing story: %@", error.description);
                                                 } else {
                                                     // Success
                                                     NSLog(@"result %@", results);
                                                 }
                                             }];
} else {
     NSLog(@"cant show the share dialog ");
}

I have thoroughly examined the code and the only difference I can find is that instead of picking an image from the gallery I am loading it from a file. As I mentioned the post goes through and is shared on Facebook however the image does not appear either on the feed or in the clickable object on the news feed. I can see a thumbnail of the image when the sharing dialog loads so I believe it is loading fine. Any help would be appreciated. Thanks in advance.

running-codebase
  • 998
  • 2
  • 12
  • 17

0 Answers0