如何分享到Facebook(iOS)

时间:2015-10-26 01:30:32

标签: ios facebook facebook-graph-api

我正在尝试使用Open Graph API将照片分享到Facebook。我不确定如何分享照片,所以我开始使用代码发布一个类似的。到目前为止,我有以下代码:

        // 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];

我在Facebook“myObject”上创建了一个自定义图形对象,并尝试在Facebook上公开分享或喜欢这个。我很乐意为此提供任何帮助,当这段代码无法显示时。理想情况下,我想向这个对象添加一张照片,并能够通过回调链接分享到我的网站(最终是应用程序)!

2 个答案:

答案 0 :(得分:1)

尝试使用shareSDK~很不错

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

答案 1 :(得分:1)

你应该在facebook app上打开图表并获取代码示例facebook auto generate: Dashboard

Code autogenerate