Facebook SDK iOS - 分享自定义故事

时间:2014-10-16 09:36:56

标签: ios objective-c facebook-graph-api

我想通过Facebook SDK for iOS分享自定义故事。我尝试以这些方式做到这一点,但它们都不起作用:

不记录任何内容

[FBGraphObject openGraphObjectForPostWithType:@"Lorem ipsum"
                                        title:@"Lorem ipsum"
                                        image:@"https://example.com/cooking-app/images/Lamb-Vindaloo.png"
                                          url:@"https://example.com/cooking-app/meal/Lamb-Vindaloo.html"
                                  description:@"Spicy curry of lamb and potatoes"];

id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:cell.params forKey:slugs[self.categoryID]];


[FBDialogs presentShareDialogWithOpenGraphAction:action
                                      actionType:[NSString stringWithFormat:@"Lorem ipsum:%@", slugs[self.categoryID]]
                             previewPropertyName:slugs[self.categoryID]
                                         handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
                                             if(error) {
                                                 NSLog(@"Error: %@", error.description);
                                             } else {
                                                 NSLog(@"Success!");
                                             }
                                         }];

操作无法完成。 (com.facebook.sdk错误5。)

[FBSession openActiveSessionWithAllowLoginUI:NO];
FBRequest *request = [FBRequest requestForPostWithGraphPath:@"/me/Lorem ipsum" graphObject:@{@"object": cell.params}];
[request setHTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
    if (!error)
    {
        // Sucess! Include your code to handle the results here
        NSLog(@"result: %@", result);
        NSString *alertTitle = @"Object successfully created";
        NSString *alertText = @"An object has been created";
        [[[UIAlertView alloc] initWithTitle:alertTitle
                                    message:alertText
                                   delegate:self
                          cancelButtonTitle:@"OK!"
                          otherButtonTitles:nil] show];
    }
    else
    {
        NSLog(@"%@", [error localizedDescription]);
    }
}];

cell.params

cell.params = [FBGraphObject openGraphObjectForPostWithType:[NSString stringWithFormat:@"Lorem ipsum:%@", slugs[self.categoryID]]
                                                      title:@"Lorem ipsum"
                                                      image:[NSString stringWithFormat:@"https://example.com/cooking-app/images/%@.png", slugs[self.categoryID]]
                                                        url:@"https://example.com"
                                                description:@"Lorem ipsum"];

cell.params[@"Lorem ipsum"] = @{@"minutes": @5, @"seconds": @37, @"hours": @1};

0 个答案:

没有答案