我已经成功地将对象及其属性的默认值发布在我的墙上。
我现在需要做的是通过我的代码手动为该对象设置这些属性。
这是我所做的:
@protocol OGApple<FBOpenGraphAction>
@property (nonatomic, retain) NSString *url;
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *image;
@property (nonatomic, retain) NSString *description;
@end
@protocol OGEatAction<FBOpenGraphAction>
@property (retain, nonatomic) id<OGApple> apple;
@end
这里的对象“apple”有四个必需的属性(url、title、image、description),,这是我设置它们的方法:
定义对象:
id<OGApple> graphObject = (id<OGApple>)[FBGraphObject graphObject];
定义动作:
id<OGEatAction> action = (id<OGEatAction>)[FBGraphObject graphObject];
设置属性(我尝试了方法1和方法二)他们都没有设置对象属性:
方法一:
[graphObject setObject:@"The Game" forKey:@"title"];
[graphObject setObject:@"https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png" forKey:@"image"];
[graphObject setObject:@"http://samples.ogp.me/267255650070428" forKey:@"url"];
方法二:
graphObject.url = @"http://samples.ogp.me/267255650070428";
graphObject.title = @"Mohammad";
graphObject.image = @"https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png";
然后将对象分配给动作:
action.apple = graphObject;
然后发布请求
[FBRequestConnection startForPostWithGraphPath:@"me/theapp:eat"
graphObject:action
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
// handle the result
if(error)
NSLog(@"%@", error);
else
NSLog(@"%@", result);
}];
请求成功发布并返回 id = xxxxxxxxxx
但是在我的时间轴上,该对象没有采用我传递给它的参数!
我错过了什么或需要在服务器上进行任何额外的配置吗?
提前致谢 :)