Search code examples
objective-cfacebook-graph-apifacebook-opengraphfacebook-ios-sdk

Tag friends by facebook ID using Open Graph in Objective C


What kind of elements does the NSArray * tags of FBOpenGraphAction expect? From the Open Graph Explorer tool it seems like it just wants some facebook IDs as fodder. However when doing that

id<OpenGraphObject> event = (id<OpenGraphObject>)[FBGraphObject graphObject];
event.url = @"http://example.com/obj1234?fb:app_id=1111&og:type=myapp:share";
id<OpenGraphShareAction> action = (id<OpenGraphShareAction>)[FBGraphObject graphObject];
action.object = event
action.tags = [NSArray arrayWithObjects:[NSNumber numberWithInt:3300252], [NSNumber numberWithInt:585025503], nil];

and then posting with

[FBRequestConnection
    startForPostWithGraphPath:@"me/myapp:share"
    graphObject:action
    completionHandler: ...
 ];

However this will not work - [__NSCFNumber dataUsingEncoding:]: unrecognized selector sent to instance


Solution

  • It looks like it doesn't expect an NSNumber, but an NSString. This would make perfect sense, given we're talking about IDs.

    Try it out and let us know how it goes