简体   繁体   English

Facebook iOS SDK错误 - 发布开放图表操作

[英]Facebook iOS SDK errors – Posting Open Graph Actions

I'm attempting to post an open graph object with an action (using stories) to Facebook, but I always receive an error that doesn't give me any details. 我试图将一个带有动作(使用故事)的开放图形对象发布到Facebook,但我总是收到一个错误,但没有给我任何细节。 I summed up all the code I'm using into a single method for you guys: 我将我正在使用的所有代码总结为一个方法给你们:

- (void)publishToGraph {
    NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject openGraphObjectForPost];
    object.provisionedForPost = YES;
    object[@"title"] = @"Example title";
    object[@"type"] = @"rs-coupcash";
    object[@"description"] = @"Example description";
    object[@"url"] = @"http://exampleurl.com/idk";
    object[@"image"] = @[@{@"url": @"http://exampleurl.com/example_url.png", @"user_generated" : @"true" }];

    [FBSession openActiveSessionWithPublishPermissions:@[@"email", @"public_profile", @"publish_actions"] defaultAudience:FBSessionDefaultAudienceFriends allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {

        if (!error && state == FBSessionStateOpen) {
            [FBRequestConnection startForPostOpenGraphObject:object completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {

                if(!error) {
                    NSString *objectId = [result objectForKey:@"id"];
                    NSLog(@"Object ID: %@", objectId);
                    id<FBOpenGraphAction> actionObject = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
                    [actionObject setObject:objectId forKey:@"coupon"];
                    [FBRequestConnection startForPostWithGraphPath:@"/me/rs-coupcash:favorite" graphObject:actionObject completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {

                        [[FBSession activeSession] close];
                        if(!error) {
                            NSLog(@"OG story posted, story ID: %@", [result objectForKey:@"id"]);
                        } else {
                            NSLog(@"Error: %@", error);
                        }
                    }];
                } else {
                    NSLog(@"Error: %@", error);
                }
            }];
        } else {
            NSLog(@"Error: %@", error);
        }
    }];
}

The error I get: 我得到的错误:

Error Domain =com.facebook.sdk Code =5 "The operation couldn't be completed. (com.facebook.sdk error 5.)" UserInfo =0x114544670 {com.facebook.sdk:HTTPStatusCode=500, com.facebook.sdk:ErrorSessionKey=, expirationDate: 2014-08-26 05:18:45 +0000, refreshDate: 2014-06-27 16:56:32 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000, **permissions**:( installed, "public_profile", email, "publish_actions" )>, com.facebook.sdk:ParsedJSONResponseKey= { body = { error = { code = 1; Error Domain = com.facebook.sdk Code = 5“操作无法完成。(com.facebook.sdk error 5.)” UserInfo = 0x114544670 {com.facebook.sdk:HTTPStatusCode = 500,com.facebook.sdk :ErrorSessionKey =,expirationDate:2014-08-26 05:18:45 +0000,refreshDate:2014-06-27 16:56:32 +0000,attemptsRefreshDate:0001-12-30 00:00:00 +0000,* *权限** :(已安装,“public_profile”,电子邮件,“publish_actions”)>,com.facebook.sdk:ParsedJSONResponseKey = {body = {error = {code = 1; message = "An unknown error has occurred."; message =“发生了未知错误。”; type = OAuthException; type = OAuthException; }; }; } ; } ; code = 500; 代码= 500; }} }}

I was using the wrong type for the open graph object; 我使用了错误的类型来打开图形对象; I was using just the namespace for the "type" value, it should be "rs-coupcash:coupon" in this case. 我只使用名称空间作为“类型”值,在这种情况下它应该是“rs-coupcash:coupon”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM