我开发了一个示例项目,我在其中显示文本和图像,并且可以将其发布在 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 的情况下做到这一点。任何人都可以帮助我吗
谢谢