Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error in using FBRequest to post open graph action in Facebook 3.5 iOS SDK

I am trying to publish an open graph action using the iOS SDK, using the following code:

[FBRequestConnection startForUploadStagingResourceWithImage:image completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        if (!error){
            NSString *uri = [result valueForKey:@"uri"];

            NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject openGraphObjectForPost];
            object.provisionedForPost = YES;
            object[@"type"] = @"myapp:Quote";
            object[@"image"] = uri;
            object[@"title"] = @"Check out my quote";

            [FBRequestConnection startForPostOpenGraphObject:object
                       completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                           if(error) {
                               NSLog(@"Error: %@", error);
                           } else {

                               NSString *graphPath = [NSString stringWithFormat:@"me/quotestagramapp.quote"];
                               [FBRequestConnection startForPostWithGraphPath:graphPath
                                                                  graphObject:object
                                                            completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                                                                if (error){
                                                                    NSLog(@"Error is %@", [error description]);
                                                                } else {
                                                                    NSLog(@"Successful");
                                                                }
                                                            }];
                           }
                       }];
        } else {
            NSLog(@"Error uploading image to fb staging");
        }
    }];

However I am getting an error and then the app crashed in my startForPostWithOpenGraphPath. Here's the error:

   *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean dataUsingEncoding:]: unrecognized selector sent to instance 0x3a9be530'
*** First throw call stack:
(0x3261c2a3 0x3a34497f 0x3261fe07 0x3261e531 0x32575f68 0x1e9ac1 0x1e9b8d 0x1eb521 0x1ec639 0x1eca19 0x1eb28d 0x1ea0f9 0x1eac49 0x1e5ca5 0x110ecb 0x1edc11 0x1ece77 0x1eaebf 0x1ef3af 0x1ef2e9 0x1ef923 0x32f576fd 0x32e971f9 0x32e97115 0x322f945f 0x322f8b43 0x32320fcb 0x3256274d 0x3232142b 0x3228503d 0x325f1683 0x325f0ee9 0x325efcb7 0x32562ebd 0x32562d49 0x3613b2eb 0x34478301 0x109bb1 0xfd3b8)
libc++abi.dylib: terminate called throwing an exception
like image 855
adit Avatar asked Nov 03 '22 22:11

adit


1 Answers

In your startForPostWithGraphPath, you're passing the "object" you just created, however, you cannot pass that as part of a open graph action. What you should do is look at the "result" that came back, get the "id" out of it, and construct an NSDictionary (or FBOpenGraphObject) with something like:

@{ @"quote": objectID}

Where objectID is the "id" from the result of the first post.

like image 148
Ming Li Avatar answered Nov 15 '22 09:11

Ming Li