2013-04-09 113 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"