3
在iOS Facebook SDK 3.5中,可以使用開放圖形API創建新故事而不需要後端服務器。使用Facebook iOS SDK將自定義故事發布到圖形API 3.5
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天,直到現在!