发布图片&使用Facebook SDK将文本发送到时间轴

时间:2013-08-12 19:02:27

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

是否可以使用Facebook SDK或Graph API创建如下所示的帖子?

enter image description here

我基本上想把这两者结合起来:

[FBRequestConnection startForUploadPhoto:[UIImage imageNamed:@"myImage"] completionHandler:nil];
[FBRequestConnection startForPostStatusUpdate:@"Hello, World!" completionHandler:nil];

感谢。

2 个答案:

答案 0 :(得分:1)

使用以下方法:

// Present share dialog
[FBDialogs presentShareDialogWithLink:params.link
                                 name:params.name
                              caption:params.caption
                          description:params.description
                              picture:params.picture
                          clientState:nil
                              handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
                                if(error) {
                                  // An error occurred, we need to handle the error
                                  // See: https://developers.facebook.com/docs/ios/errors
                                  NSLog([NSString stringWithFormat:@"Error publishing story: %@", error.description]);
                                } else {
                                  // Success
                                  NSLog(@"result %@", results);
                                }
                              }];

以下是参考:https://developers.facebook.com/docs/ios/share

答案 1 :(得分:0)

试试这个,

        FBRequestConnection *connection = [[FBRequestConnection alloc] init];

        NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
        [dictionary setObject:UIImagePNGRepresentation(_image) forKey:@"picture"];

        if (message) {
            [dictionary setObject:message forKey:@"message"];
        }
        FBRequest *request = [FBRequest requestWithGraphPath:@"me/photos" parameters:dictionary HTTPMethod:@"POST"];
        [connection addRequest:request completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {

        }];

        [connection start];