7
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               photoDescription, @"message",
                               image, @"image",
                               nil];


[facebook requestWithGraphPath:@"me/photos"
                                    andParams:params
                                andHttpMethod:@"POST"
                                  andDelegate:self];

这就是我将图像上传到 Facebook 的方法。图片已成功上传到 Facebook 'photos'。但我想将图像发布到我的 Facebook 订阅源。所以我尝试了,

[facebook requestWithGraphPath:@"me/feed"
                                    andParams:params
                                andHttpMethod:@"POST"
                                  andDelegate:self];

但它仍然是发布到“照片”的图像。它没有出现在Feed中...

我搜索并使用了不同的方法来解决问题,但我找不到任何有用的东西......

4

2 回答 2

0
UIImage* image=...;
if ([FBSession.activeSession.permissions
         indexOfObject:@"publish_actions"] == NSNotFound) {

        NSArray *permissions =
        [NSArray arrayWithObjects:@"publish_actions",@"publish_stream", nil];
        [[FBSession activeSession] requestNewPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceFriends
                                              completionHandler:^(FBSession *session, NSError *error) {}];
    }
    else
    {
    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
    [params setObject:@"Photo post test..." forKey:@"message"];
    [params setObject:UIImagePNGRepresentation(image) forKey:@"picture"];
    //for not allowing multiple hits

        [FBRequestConnection startWithGraphPath:@"me/photos"
                                 parameters:params
                                 HTTPMethod:@"POST"
                          completionHandler:^(FBRequestConnection *connection,
                                              id result,
                                              NSError *error)
     {
         if (error)
         {
             //showing an alert for failure
             UIAlertView *alertView = [[UIAlertView alloc]
                                       initWithTitle:@"Post Failed"
                                       message:error.localizedDescription
                                       delegate:nil
                                       cancelButtonTitle:@"OK"
                                       otherButtonTitles:nil];
             [alertView show];

         }
         else
         {
             //showing an alert for success
             UIAlertView *alertView = [[UIAlertView alloc]
                                       initWithTitle:@"Post success"
                                       message:@"Shared the photo successfully"
                                       delegate:nil
                                       cancelButtonTitle:@"OK"
                                       otherButtonTitles:nil];
             [alertView show];

         }
     }];
    }
于 2013-12-17T11:05:10.680 回答
0

不知道你的params样子,但试试这个..

UIImage *image = ...// some image.

NSData *imageData= UIImagePNGRepresentation(image);

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                           @"some message", @"message", imageData,@"source", nil];

[facebook dialog:@"feed" andParams:params andDelegate:self];
于 2012-05-31T09:29:10.247 回答