我已成功将该对象发布到我的墙上,并使用其属性的默认值。
我现在需要做的是通过我的代码手动设置该对象的这些属性。
这就是我所做的:
@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和方法2)没有设置对象属性:
方法一:
[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
但是在我的时间轴上,对象没有采用我传给它的参数!
我在服务器上是否遗漏了某些内容或需要额外的配置?
提前致谢:)