简体   繁体   中英

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)!

try to use shareSDK~ it's nice

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

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

Code autogenerate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM