Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Post on Facebook page as admin iOS Facebook SDK

I need to make a post on a my own fanpage as the admin. I created this code hopping that passing the id of the page "fbPageID" would leave the post on that page, but it actually leaves the post on my profile.

NSArray *publishPerms = @[@"manage_pages",@"publish_actions", @"publish_stream"];
[FBSession openActiveSessionWithPublishPermissions:publishPerms     defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:NO completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
        if (session.isOpen) {
            [FBRequestConnection startForPostStatusUpdate:self.textBox.text place:fbPageID tags:nil completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                if (error){
                    NSLog(@"error %@",error);
                }
                else{
                    NSLog(@"POSTED %@",result);
                }

            }];
        }
        else{
            NSLog(@"session not open");
        }
like image 686
user3679492 Avatar asked Nov 01 '22 23:11

user3679492


1 Answers

This is helpfull for Post on user Facebook..

  1. Step 1 - Import FBSDK in your project

  2. Step 2 - Login Authentication

    NSDictionary *params = @{
    @"message": @"This is a test message",
                             };
    /* make the API call */
    FBSDKGraphRequest *request_ = [[FBSDKGraphRequest alloc]
                                  initWithGraphPath:@"/me/feed"
                                  parameters:params
                                  HTTPMethod:@"POST"];
    [request_ startWithCompletionHandler:^(FBSDKGraphRequestConnection   *connection,
                                          id result,
                                          NSError *error) {
        // Handle the result
    }];
    
like image 90
Lokesh Avatar answered Nov 15 '22 06:11

Lokesh