1

I am using SLComposeViewController framework to create Facebook connectivity through iPhone app, to post feeds from my app to Facebook.

However, i want to use a particular account for e.g. myCompanyName account to post on Facebook. It will be like following:

Click on post to Facebook button -> myCompanyName account will be like an intermediate account and on its wall my posts will be displayed -> Once done post data to user's personal fb account.

So whenever user will see post on his wall, he will see posted via "myCompanyName".

How do i do this?

Right now I am posting directly to user's wall using follwing code:

  SLComposeViewController *controllerSLC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

  [controllerSLC addURL:[NSURL URLWithString:someurl]];

  [controllerSLC addImage:[UIImage imageNamed:@"someimg.png"]];

  [self presentViewController:controllerSLC animated:YES completion:Nil];

Please help.

iOSDev
  • 3,617
  • 10
  • 51
  • 91

1 Answers1

2

Try this code...

NSArray *permissions = [[NSArray alloc] init];
    [NSArray arrayWithObjects:@"email", nil];

    [FBSession openActiveSessionWithReadPermissions:permissions
                                       allowLoginUI:YES
                                  completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
                                      /* handle success + failure in block */
                                  }];
    NSString *appId = @"4154637324343248";
NSString *msg = @"Hello World! This is my first post from my app";
    NSString *senderName = @"XXXXX";
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   appId, @"api_Key",
                                   msg, @"Message",
                                   senderName, @"Name",
                                   nil];
    [FBRequest requestWithGraphPath:@"me/feed" parameters:params HTTPMethod:@"POST"];

Before to run this you need configure your facebook account with the device built in app in Settings, if not facebook login page will be displayed

User-1070892
  • 929
  • 10
  • 16
  • Following error is displayed: No known class method for selector 'openActiveSessionWithReadPermissions:allowLoginUI:completionHandler:' – iOSDev May 01 '13 at 05:48
  • 1
    Go to developer.facebook.com and register yourself as a developer and download facebook latest sdk, import it in to your project #import , also you can get AppId there. – User-1070892 May 01 '13 at 06:52
  • 1
    Integrating to native ios apps >> https://developers.facebook.com/docs/howtos/ios-6/ – User-1070892 May 01 '13 at 07:13