parseで認証してfacebookのopen graph storyを投稿する

メモ

    FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
    photo.image = shareImage;
    
    NSDictionary *properties = @{
                                 @"og:type": @"hoge:huga",
                                 @"og:title":@"title",
                                 @"og:description":@"description",
                                 @"og:url": @"http://hogehoge.hugahuga",
                                 @"og:image": @[photo]
                                 };
    FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
    
    FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
    action.actionType = @"hoge:huga";
    [action setObject:object forKey:@"huga"];
    [action setString:@"true" forKey:@"fb:explicitly_shared"];
    [action setString:@"this is user message" forKey:@"message"];
    
    FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
    content.action = action;
    content.previewPropertyName = @"playlist";
    
    [FBSDKShareAPI shareWithContent:content delegate:self];

まとめ

注意点としては以下の条件でフィードに出なくなる

  • fb:explicitly_sharedがついていない
  • 審査が通っていないアプリで、かつテストユーザではない

ここではまるとめんどくさいのでご注意を