ios facebook用户发布图片

时间:2014-04-22 12:52:37

标签: ios objective-c facebook

我不知道如何让用户发布图片 这里是我的代码,这返回用户名和用户ID,用户图片,但我希望用户发布图片,发表评论请帮帮我

这是我的代码,仅用于用户信息,这是有效的,但Feed代码无效

if (FBSession.activeSession.isOpen) {

    NSLog(@">>>> facebook >>>>");
    [[FBRequest requestForMe] startWithCompletionHandler:
     ^(FBRequestConnection *connection,
       NSDictionary<FBGraphUser> *user,
       NSError *error) {
         if (!error) {
             NSLog(@"%@",user);
             username=user.name;
         //    NSLog(@"%@",username);
           //  NSLog(@"%@",user.id);
             userid=user.id;
           //  [self saviuserid];

       //      [self saveName];

             NSLog(@">>name>>> %@",user.link);
             stringImage = [NSString stringWithFormat:@"https://graph.facebook.com/%@/picture", user.id];

             NSLog(@">>image link>>> %@",stringImage);

             // get feeds
             NSString *fdfd =[NSString stringWithFormat:@"https://graph.facebook.com/%@/feed", user.id];

                 NSLog(@">>fsdsd>>> %@",fdfd);




             if (checkfornextpage == true) {



             LoginViewController *flipViewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:[NSBundle mainBundle]];
              flipViewController.getUserimg =stringImage;
               flipViewController.getUserName =username;
             //   [self.navigationController pushViewController:flipViewController animated:YES];
              [self presentViewController:flipViewController animated:YES completion:nil];
             }

         }
         else{

         }
     }];
}

我在这里通过了一个不起作用的代码

NSString *fdfd =[NSString stringWithFormat:@"https://graph.facebook.com/%@/feed", user.id];

                     NSLog(@">>fsdsd>>> %@",fdfd);

现在我试试这个但是这个返回data = {}这个结果没有任何信息

[FBRequestConnection startWithGraphPath:@"me/feed"
                                           completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                                               if (!error) {
                                                NSLog(@"Resul %@", result);
                                               }
                                           }
                      ];

,输出是make url,没有数据

https://graph.facebook.com/100005440749818/feed?format=json&access_token=CAAUTJQ2n428BAOlBQsZBhyMpac77tBCsFLBP3ud2Bj2yfX7caqJSzUJ76ljfuSrYNtyZBcOGSSdqHo9f7zarJ7YRKZAAbpMGjyWMcb5n0mggbYxodCuWBUnZBC1zvFppAt4ciAzgwUVQuGjXh7EUcBaZBxscQmkzaXOsYtcP5QrMh1p5y4hEZAXTdA6xOfDh9IJKLV7bKXUi1JHYfeH8SYT0CT65ww0YEZD&limit=25&since=1397743992&__previous=1

1 个答案:

答案 0 :(得分:0)

有关发出请求的iOS SDK信息,请参阅: https://developers.facebook.com/docs/reference/ios/3.1/class/FBRequestConnection#startWithGraphPath%3AcompletionHandler%3A

因此,如果您想看一张专辑的照片,给定一个album_id,您可以使用以下请求代码:

[FBRequestConnection startWithGraphPath:@"<album_id>/photos" 
    completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
       if (!error) {
           NSLog("Results: %@", result);
       }
    }
];

确保您首先要求获得user_photos权限。