How can I share game achievement through open graph?

381 Views Asked by At

I want to share game achievement story to facebook through Open Graph Here's the code for creating an open graph object

NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject openGraphObjectForPost];
        object.provisionedForPost = YES;
        object[@"title"] = @"Playing";
        object[@"type"] = @"game.achievement";
        object[@"description"] = @"I just hit 1000 km";
        object[@"url"] = @"https://www.facebook.com/";
        object[@"image"] = @[@{@"url": [result objectForKey:@"uri"], @"user_generated" : @"false" }];
        object[@"game:points"] = @"100";
[FBRequestConnection
                startForPostOpenGraphObject:object
                completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {}];

And I am getting this error message

Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)"

and this is response body

body =     {
    error =         {
        code = 100;
        message = "(#100) Object Missing a Required Value: Object at URL 'https://www.facebook.com/' of type 'game.achievement' is invalid because a required property 'game:points' of type 'integer' was not provided.";
        type = OAuthException;
    };
};
code = 400;

I know the error is self explanatory but how can I pass an integer value to dictionary. Also I did try to pass the NSNumber value but no luck. Here's the document link of game achievement object Sharing game achievement using open graph object

1

There are 1 best solutions below

0
On

Here is the answer that worked for me.

Just wrap it inside data values:

object[@"data"][@"game:points"] = @"100";