2013-04-09 109 views
1

我开发了一个示例项目,其中显示文本和图像,我可以将它发布到Facebook墙上。我已经表明了代码和它下面的图像。这看起来像我们如何将照片添加到我们的墙状态消息如何在不使用开放图形API的情况下在Facebook墙上发布图像和文本

- (IBAction)postStatusUpdateClick:(UIButton *)sender 
{ 
    UIImage *image =[UIImage imageNamed:@"[email protected]"]; 


    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

后的图像与FB墙上的文字,而无需使用开放图形API >>http://xcodenoobies.blogspot.com.au/2012/09/how-to-upload-photo-and-update-status.html

更新回答

帖子我法师和文本在Facebook上使用FB的iOS SDK https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/

干杯, 拉维

+0

我已经做了这样..现在我想要做像我有我的问题出在图像2 – raptor 2013-04-11 03:28:22

+0

不知道,如果你可以在没有Open Graph API的情况下完成这些小事。 – 2013-04-11 12:13:00

+0

您是否知道如何使用开放图API来实现它? – raptor 2013-04-11 16:49:12

1

只要打开这个网址在移动safari.It将显示对话框份额

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