在 iOS Facebook SDK 3.5 中,据说有一种方法可以使用开放图形 API 创建新故事,而无需后端服务器。
Facebook.com 上的文档/教程仅显示了它是如何使用后端服务器完成的,并且在互联网上似乎没有我可以找到的工作代码。
我已经设法根据一小段代码将以下代码放在一起,但它不起作用:
NSMutableDictionary<FBOpenGraphObject> *event = [FBGraphObject openGraphObjectForPost];
event[@"type"] = @"leaf-events:event";
event[@"title"] = @"Adam's Birthday";
NSMutableDictionary<FBGraphObject> *action = [FBGraphObject openGraphActionForPost];
action[@"event"] = event;
[FBRequestConnection startForPostWithGraphPath:@"me/leaf-events:create"
graphObject:action
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSLog(@"Result: %@", result);
NSLog(@"Error: %@", error.userInfo);
}];
此代码崩溃并告诉我:
2013-06-19 19:40:01.451 Events[1150:60b] Error: {
"com.facebook.sdk:ErrorSessionKey" = "<FBSession: 0x1650fe80, state: FBSessionStateOpen, loginHandler: 0x1651dc20, appID: 474218799329968, urlSchemeSuffix: , tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x16549810>, expirationDate: 4001-01-01 00:00:00 +0000, refreshDate: 2013-06-19 18:39:57 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(\n \"basic_info\"\n)>";
"com.facebook.sdk:HTTPStatusCode" = 400;
"com.facebook.sdk:ParsedJSONResponseKey" = {
body = {
error = {
code = 3503;
message = "(#3503) \"{\"type\":\"leaf-events:event\",\"data\":{},\"title\":\"Adam's Birthday\",\"fbsdk:create_object\":true}\" is an invalid value for property \"event\" with type \"Reference\"";
type = OAuthException;
};
};
code = 400;
};
}
任何人都可以帮助我并提供有关如何完成这个看似简单的任务的示例代码,我已经坚持了 2 天了!