2012-11-30 61 views
4

这可能是一个愚蠢的问题,但我无法弄清楚在哪里添加fb:explicit_shared布尔。我在哪里发布fb:explicit_shared iOS版sdk

使用Graph API Explorer时,我可以做到这一点,只需添加字段并将其设置为'true'即可。奇迹般有效。

但是,当我尝试从我的iOS应用程序做到这一点,它根本无法工作。

- (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; 
} 

这是直接从open graph tutorial采取的大部分,除了在那里我已经添加了FB:explicitly_shared位。

从iOS设备发布时,我需要在哪里添加此内容?任何帮助是非常赞赏:)

回答

11

您需要的参数添加到行动,什么我可以从你的代码告诉,似乎您试图将其添加到对象,这显然赢了没有工作。 这是我如何做的:

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

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

(注意GSOGTrackActivityAction是我的类型化访问操作对象的自定义协议和“轨迹”是我的动作和“活动”是我对象(在打开图。 )。)

+0

谢谢LukášPetr,那完全正确。现在一切正常。我感谢你的回应。 – Warblr

+0

欢迎您:) –

相关问题