1

我正在尝试从我的 iOS 游戏中发布一个对象。我仔细检查了权限,然后复制并粘贴了 Facebook 给我的代码,但它不起作用:S

任何想法?

NSMutableDictionary<FBGraphObject> *object =
[FBGraphObject openGraphObjectForPostWithType:@"game:level"
                                        title:@"Sample Level 2"
                                        image:@"https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png"
                                          url:@"http://samples.ogp.me/367110273423562"
                                  description:@""];;

object[@"create_object"] = @"1";
object[@"fbsdk:create_object"] = @"1";

[FBRequestConnection startForPostWithGraphPath:@"me/objects/game:level"
                                   graphObject:object
                             completionHandler:^(FBRequestConnection *connection,
                                                 id result,
                                                 NSError *error) {
                                 // handle the result
                                 NSLog(@"Result: %@",error);
                             }];

错误回调:

Result: Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x1690d1d0 {com.facebook.sdk:HTTPStatusCode=400, com.facebook.sdk:ParsedJSONResponseKey={
    body =     {
        error =         {
            code = 2500;
            message = "Cannot specify type in both the path and query parameter.";
            type = OAuthException;
        };
    };
    code = 400;
}, com.facebook.sdk:ErrorSessionKey=<FBSession: 0xae21820, state: FBSessionStateOpen, loginHandler: 0xc1279f0, appID: 358605784274011, urlSchemeSuffix: , tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0xae227a0>, expirationDate: 2013-12-07 05:14:08 +0000, refreshDate: 2013-10-08 14:48:02 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(
    "basic_info",
    installed,
    "user_location",
    email,
    "user_friends",
    "user_birthday",
    "publish_actions"
)>}

我尝试搜索解决方案,但在 iOS 上找不到

谢谢

4

2 回答 2

3

You're receiving the error Cannot specify type in both the path and query parameter because both the object and the graphPath parameters contain the object type, i.e. game:level. Instead of passing @"me/objects/game:level", just use @"me".

于 2013-10-09T04:26:31.270 回答
1

I was having the same problem, but solved it by creating the object and action type on the open graph section of the app. For creating the actions and the objects for an refer this link. It has a great example for posting the custom stories. And if you have already created the objects and the actions then recheck for the namespace and calling of the actions on the objects.

于 2014-05-09T10:31:28.600 回答