Brian Daneshgar
Brian Daneshgar

Reputation: 343

How to share to Facebook (iOS)

I'm trying to share a photo to Facebook using the Open Graph API. I was unsure of how to share a photo so I'm starting off with code to just post a like. So far I have the following code:

        // Create an object
        NSDictionary *properties = @{
                                     @"og:type": @"myObject",
                                     @"og:title": @"title",
                                     @"og:description": @"description",
                                     };
        FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];


        // Create an action
        FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
        action.actionType = @"og.likes";
        [action setObject:object forKey:@"myObject"];

        // Create the content
        FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
        content.action = action;
        content.previewPropertyName = @"myObject";


        [FBSDKShareDialog showFromViewController:self
                                     withContent:content
                                        delegate:nil];

I created a custom graph object on Facebook "myObject" and am trying to share or like this publicly on Facebook. I would love any help on this, when this code runs nothing shows up. Ideally I would like to add a photo to this object and be able to share it with a callback link to either my site (and eventually the app)!

Upvotes: 1

Views: 149

Answers (2)

vien vu
vien vu

Reputation: 4337

You should go to open graph on facebook app and get code sample facebook auto generate: Dashboard

Code autogenerate

Upvotes: 1

Louyw
Louyw

Reputation: 11

try to use shareSDK~ it's nice

link: http://www.mob.com/en

Upvotes: 1

Related Questions