iOS,Facebook,GraphAPI问题

时间:2016-06-06 00:56:29

标签: ios facebook facebook-graph-api

我需要允许用户在iOS应用上发布Facebook信息,以下几乎是我想要的,但是:

  1. 我显然不想要ISBN,因为应用程序中的信息(实际上是来自其他用户的帖子)并不是可以被描述为“书籍”的书。并且没有ISBN
  2. 我需要以某种方式附加应用程序的徽标。现在它只是一个脚注。我只能附上一张图片,但需要第二张图片,即徽标。
  3. 任何人都可以提出我应该使用的其他架构,如果没有,可以使用#books; book.book'这将正确表达意义:"用户A读取(或喜欢)用户B"的帖子。

    现在FB的帖子看起来如何:

    enter image description here

    我正在使用的代码如下:

    NSString *title = self.currSelecectedContextCell.uploaderDemoLabel.text;
    NSURL *imageURL = self.currSelecectedContextCell.upload.screenshotURL;
    NSString *description = self.currSelecectedContextCell.contextLabel.text;
    NSDictionary *properties = @{
                                 @"og:type": @"books.book",
                                 @"og:title": title,
                                 @"og:image": imageURL,
                                 @"og:description": description,
                                 @"books:isbn": @"0-553-57340-3",
                                 };
    FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
    
    // Create an action
    FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
    action.actionType = @"books.reads";
    [action setObject:object forKey:@"books:book"];
    
    FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
    content.action = action;
    content.previewPropertyName = @"books:book";
    
    [FBSDKShareDialog showFromViewController:self
                                 withContent:content
                                    delegate:nil];
    

1 个答案:

答案 0 :(得分:2)

以下列方式解决:

NSString *title = self.currSelecectedContextCell.uploaderDemoLabel.text;
NSURL *imageURL = self.currSelecectedContextCell.upload.screenshotURL;
NSString *description = self.currSelecectedContextCell.contextLabel.text;
NSDictionary *properties = @{
                             @"og:type": @"object",
                             @"og:url":@"http://www.textpertapp.co/",
                             @"og:title": title,
                             @"og:image": imageURL,
                             @"og:description": description
                             };
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];

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

FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = @"object";

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