Reputation: 1552
I've been struggling with this for the last couple of days and can't seem to find a solution.
Here is the problem: I am trying to publish Open Graph story from my iOS app and let Facebook scrape the provided url for additional Open Graph tags. This worked well in previous SDK (3.x) but for the life of me I can't figure out why it stopped working with 4.2.0.
The error I am getting is this:
Object Missing a Required Value: Object at URL 'http://samples.ogp.me/487842374583398' of type 'routieapp:activity' is invalid because a required property 'og:title' of type 'string' was not provided.
I've included the sample OpenGraph page of my Open Graph action provided by Facebook just to see if the problem was in my live website that contains the tags, but clearly, since it fails even with their site, that is not the case.
You can see from the source of the sample website that it indeed contains all the Open Graph tags:
<meta property="fb:app_id" content="202373013130337" />
<meta property="og:title" content="Sample Activity" />
<meta property="og:image" content="https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png" />
<meta property="og:url" content="http://samples.ogp.me/487842374583398" />
<meta property="og:type" content="routieapp:activity" />
Here is the code I am using to initiate the sharing:
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:@{@"og:url": @"http://samples.ogp.me/487842374583398", @"og:type": @"routieapp:activity"}];
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = @"routieapp:track";
[action setString:[GSDateFormatter ISO8601StringFromDate:[route.startLocation timestampAsDate]] forKey:@"start_time"];
[action setString:[GSDateFormatter ISO8601StringFromDate:[route.endLocation timestampAsDate]] forKey:@"end_time"];
NSTimeInterval duration = [[route.endLocation timestampAsDate] timeIntervalSinceDate:[route.startLocation timestampAsDate]];
[action setNumber:@(duration) forKey:@"activity_duration"];
[action setObject:object forKey:@"routieapp:track"];
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = @"routieapp:track";
FBSDKShareAPI *shareObject = [[FBSDKShareAPI alloc] init];
shareObject.shareContent = content;
shareObject.message = route.name;
shareObject.delegate = self;
[shareObject share];
[FBSDKShareAPI shareWithContent:content delegate:self];
Now regarding my Open Graph setup: track is the action and activity is the object.
Any ideas how to solve this? I'd be thrilled! Because I've been hitting the wall with this for almost a week and I've run out of ideas. You (people on Stack Overflow) are my last hope! Thank you very much in advance.
Upvotes: 1
Views: 307
Reputation: 1552
Solved! :)
But you wouldn't believe where the problem turned out to be. This line:
[action setNumber:@(duration) forKey:@"activity_duration"];
caused it all. There is no activity_duration parameter when it comes to actions. It's a shame that the error message wasn't more descriptive.
Also, if you need to share Open Graph object, there is a better way to do it than I did it in the code in the question - you can use this method:
FBSDKShareOpenGraphAction *action = [FBSDKShareOpenGraphAction actionWithType:@"routieapp:track" objectURL:objectURL key:@"routieapp:activity"];
Upvotes: 1