如何在不使用开放图形API的情况下在Facebook墙上发布图像和文本

时间:2013-04-09 19:11:11

标签: iphone ios objective-c facebook

我开发了一个示例项目,我正在显示文本和图像,我可以在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];
}

enter image description here

*****现在我希望以适当的格式显示,就像在facebook中一个美味的例子中那样。** enter image description here

我想在没有开放图形api的情况下这样做。任何人都可以帮助我

由于

2 个答案:

答案 0 :(得分:2)

在FB Wall上使用文本发布图像而不使用Open Graph API>> 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/

干杯, 拉维

答案 1 :(得分:1)

只需在移动版Safari中打开此网址即可显示共享对话框

    "http://www.facebook.com/dialog/feed?fbapp_id=yorfbappId&name=Test&description=test&redirect_uri=fbyourfbappid%3A%2F%2Fauthorize&sdk=ios"