Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do I post fb:explicitly_shared for iOS sdk

Tags:

ios

facebook

sdk

This may be a dumb question, but I cannot figure out where to add the fb:explicitly_shared bool.

I'm able to make this work when using the Graph API Explorer, simply by adding the field and setting it to 'true'. Works like a charm.

But when I try to do this from within my iOS app, it simply does NOT work.

- (id<OGObject>)myObjectForObject:(NSDictionary*)object
{

    NSString *format =
    @"http://www.myurl.com/fbobjects/object.php?"
    @"fb:app_id=<my_app_id>&og:type=%@"
    @"&fb:explicitly_shared=true"
    @"&og:title=%@"
    @"&og:description=%@"
    @"&og:image=http://www.myimageurl.com/image.png"
    @"&body=%@";

    id<OGObject> result = (id<OGObject>)[FBGraphObject graphObject];

    // Give it a URL that will echo back the name of the wod as its title,
    // description, and body.
    result.url = [NSString stringWithFormat:format,
                  @"myapp_namespace:object",
                  [object objectForKey:@"title"],
                  [object objectForKey:@"description"],
                  [object objectForKey:@"title"]];

    NSLog(@"%@", result.url);

    return result;
}

This is taken directly from the open graph tutorial for the most part, except for where I've added the fb:explicitly_shared bit.

Where do I need to add this when posting from an iOS device? Any help is much appreciated :)

like image 749
Warblr Avatar asked Dec 20 '22 12:12

Warblr


1 Answers

You need to add the parameter to the action, and what I can tell from your code, it seems that you are trying to add it to the object, which obviously won't work. Here is how I did it:

id<GSOGTrackActivityAction> action = (id<GSOGTrackActivityAction>)[FBGraphObject graphObject];
action.activity = activityObject;

[(NSMutableDictionary *)action setValue:@"true" forKey:@"fb:explicitly_shared"];

(Note that GSOGTrackActivityAction is my custom protocol for typed access to the action object. And "track" is my action and "activity" is my object (in the Open Graph).)

like image 97
Lukas Petr Avatar answered Jan 06 '23 05:01

Lukas Petr