I have followed the tutorial about posting a custom Open Graph story using the Facebook SDK for iOS: https://developers.facebook.com/docs/ios/open-graph/

I have also read the docs about flexible sentence structures here: https://developers.facebook.com/docs/opengraph/creating-custom-stories/#variations

My question is, how and where do I specify in the code which specific sentence structure to use? I want to post "John Doe cooked a Steak" instead of "John Doe cooked a meal". I want to use the One-to-One sentence structure instead of the One-to-One Without Object Title structure.

// Create an object
id<FBGraphObject> object =
[FBGraphObject openGraphObjectForPostWithType:@"myapp:meal"
                                        title:@"Steak"
                                        image:@"http://i.imgur.com/g3Qc1HN.png"
                                          url:@"https://example.com/link/"
                                  description:@"Juicy and medium-rare"];

// Create an action
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];

// Link the object to the action
[action setObject:object forKey:@"meal"];

// Check if the Facebook app is installed and we can present the share dialog
FBOpenGraphActionShareDialogParams *params = [[FBOpenGraphActionShareDialogParams alloc] init];
params.action = action;
params.actionType = @"myapp:cook";

// If the Facebook app is installed and we can present the share dialog
if([FBDialogs canPresentShareDialogWithOpenGraphActionParams:params])
{
    // Show the share dialog
    [FBDialogs presentShareDialogWithOpenGraphAction:action
                                          actionType:@"myapp:cook"
                                 previewPropertyName:@"recipe"
                                             handler:
     ^(FBAppCall *call, NSDictionary *results, NSError *error)
    {
        if(error) {
            // There was an error
            NSLog(@"Error publishing story: %@", error.description);
        } else {
            // Success
            NSLog(@"result %@", results);
        }
    }];
}
有帮助吗?

解决方案

I'm trying to figure that out also and here's why I understand so far:

  • By default, all posts are published on past tense. "Username ate a pizza"
  • If you want to use present tense, you have to set "end_time" attribute like this:

    [action setEnd_time:@"2014-03-08T23:23:23"]; //a date on the future

    This will look on user's timeline like "Username is eating a pizza" and that will continue showing like that until the date specified by end_time arrives. I think that there could be an issue with time zones that I'm currently experiencing, so be careful if you need to handle different time zones.

  • According to documentation, "expires_in" attribute is a shortcut for "end_time" but instead of using a datime object, you can use a seconds delta, something like "this is in present tense until 500 seconds passed since it's been published", but I haven't been able to make this work (posts always shows as past tense)

    [action setExpires_time:@"500"];

  • All other flexible sentences structures are managed by Facebook and you can't control when to show them. For instance, if two users of your app share content from it, it will show on friend's timeline something like "user1 and user2 are eating a pizza".

If you find out something else, please, update your post

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top