0

Upgrading my app. Target is iOS5.1. Xcode 4.5.2 and am using FacebookSDK 3.0 along with Twitter Frameworks. App is logging into Facebook without issue. When I attempt to publish a post, I get this returned in the log:

2012-12-18 10:39:31.934 MyApp[31754:1d603] Error Domain=com.facebook.sdk Code=5 
"The operation couldn’t be completed. (com.facebook.sdk error 5.)" 
UserInfo=0xab74630 {com.facebook.sdk:ParsedJSONResponseKey={
    body =     {
        error =         {
            code = 100;
            message = "(#100) Missing message or attachment";
            type = OAuthException;
        };
    };
code = 400;
}, com.facebook.sdk:HTTPStatusCode=400}
2012-12-18 10:39:31.935 MyApp[31754:1d603] (null)

This last line is the result of a log expression to list the "postParams" in the "publishStory" method listed below. Note that it is (null). The error result in simulator is "error: domain = com.facebook.sdk, code = 5"

I used the Facebook tutorial to build the FB interface. I've got the params listed in initWithNibName, just as the tutorial indicates.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // this stuff will change... just get it working

        self.postParams = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
                           @"Share...", @"message",
                           @"http://MyApp.com", @"link",
                           @"icon.png", @"picture",
                           @"MyApp", @"name",
                           @"A wonderful way to record your life events.", "caption",
                           @"Easy to use.", @"description",
                           nil];
    }
    return self;
}

Then, the "publish" is in a separate method, which is where it stops and I get the above error.

- (void)publishStory
{
    [FBRequestConnection
    startWithGraphPath:@"me/feed"
    parameters:_postParams
    HTTPMethod:@"POST"
    completionHandler:^(FBRequestConnection *connection,
                     id result,
                     NSError *error) {
        NSString *alertText;
        if (error) {
            NSLog(@"%@",error);
            NSLog(@"%@", _postParams);
            alertText = [NSString stringWithFormat:
                      @"error: domain = %@, code = %d",
                      error.domain, error.code];
        } else {
            alertText = [NSString stringWithFormat:
                      @"Posted action, id: %@",
                      [result objectForKey:@"id"]];
        }
        // Show the result in an alert
        [[[UIAlertView alloc] initWithTitle:@"Result"
                                 message:alertText
                                delegate:self
                       cancelButtonTitle:@"OK!"
                       otherButtonTitles:nil]
        show];
    }];
}

I think, that the actual params are not being uploaded. I've been searching for several days trying to find a solution. Anyone have an idea of how to fix this and get the post to complete? Any help would be greatly appreciated!

4

1 に答える 1