1

我开发了一个示例项目,我在其中显示文本和图像,并且可以将其发布在 facebook 墙上。我在下面显示了代码和它的图像。这就像我们如何将照片添加到墙上并显示状态消息

- (IBAction)postStatusUpdateClick:(UIButton *)sender
{
    UIImage *image =[UIImage imageNamed:@"Icon-72@2x.png"];


    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
    [params setObject:@"Test with Image" forKey:@"message"];
    [params setObject:UIImagePNGRepresentation(image) forKey:@"picture"];
    shareOnFacebook.enabled = NO; //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
             [self showAlert:@"Facebook unable to share photo " result:result error:error];
         }
         else
         {
             //showing an alert for success
             [self showAlert:@"Facebook share photo successful" result:result error:error];
         }
         shareOnFacebook.enabled = YES;
     }];
}


// UIAlertView helper for post buttons
- (void)showAlert:(NSString *)message
           result:(id)result
            error:(NSError *)error {

    NSString *alertMsg;
    NSString *alertTitle;
    if (error) {
        alertTitle = @"Error";
        if (error.fberrorShouldNotifyUser ||
            error.fberrorCategory == FBErrorCategoryPermissions ||
            error.fberrorCategory == FBErrorCategoryAuthenticationReopenSession) {
            alertMsg = error.fberrorUserMessage;
        } else {
            alertMsg = @"Operation failed due to a connection problem, retry later.";
        }
    } else {
        NSDictionary *resultDict = (NSDictionary *)result;
        alertMsg = [NSString stringWithFormat:@"Successfully posted '%@'.\nPost ID: %@",
                    message, [resultDict valueForKey:@"id"]];
        alertTitle = @"Success";
    }

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:alertTitle
                                                        message:alertMsg
                                                       delegate:nil
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil];
    [alertView show];
}

在此处输入图像描述

*****现在我想以正确的格式显示,就像来自 facebook 的美味示例一样。** 在此处输入图像描述

我想在没有 open graph api 的情况下做到这一点。任何人都可以帮助我吗

谢谢

4

2 回答 2

2

不使用 Open Graph API 在 FB 墙上发布带有文本的图像 >> http://xcodenoobies.blogspot.com.au/2012/09/how-to-upload-photo-and-update-status.html

更新的答案

使用 FB iOS SDK 在 facebook 上发布图像和文本 https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/

干杯,拉维

于 2013-04-11T01:11:38.727 回答
1

只需在移动 safari 中打开此 url。它将显示共享对话框

    "http://www.facebook.com/dialog/feed?fbapp_id=yorfbappId&name=Test&description=test&redirect_uri=fbyourfbappid%3A%2F%2Fauthorize&sdk=ios"
于 2013-04-10T02:34:32.297 回答