Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6834677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:08:28+00:00 2026-05-26T23:08:28+00:00

I am doing a reader application which can send text to Facebook. But I

  • 0

I am doing a reader application which can send text to Facebook. But I completed the login to Facebook in another page. I have a button called ‘textpostingbtn‘ and a textview which holds the text. What I need to do is, when the user taps the button it posts the text to Facebook without showing the login dialog. I have some validation on the button so the button is enabled only if the user is logged in. link that i used in login purpose.

EDIT:

- (IBAction)postGradesTapped:(id)sender {
    //_posting = YES;
    // If we're not logged in, log in first...
    if (![_session isConnected]) {
        self.loginDialog = nil;
        _loginDialog = [[FBLoginDialog alloc] init];    
        [_loginDialog show];

        _logoutButton.hidden = YES;
    }
    // If we have a session and a name, post to the wall!
    //else if (_facebookName != nil) {
    //[self postToWall];
    //}
    // Otherwise, we don't have a name yet, just wait for that to come through.

}

- (IBAction)logoutButtonTapped:(id)sender {
    [_session logout];
    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"FB_logged"];
    _btnFacebookmain.enabled =NO;
}


#pragma mark FBSessionDelegate methods

- (void)session:(FBSession*)session didLogin:(FBUID)uid {
    [self getFacebookName];

}

- (void)session:(FBSession*)session willLogout:(FBUID)uid {
    _logoutButton.hidden = YES;
    _facebookName = nil;
}

#pragma mark Get Facebook Name Helper

- (void)getFacebookName {
    NSString* fql = [NSString stringWithFormat:
                     @"select uid,name from user where uid == %lld", _session.uid];
    NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
    [[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
}

#pragma mark FBRequestDelegate methods

- (void)request:(FBRequest*)request didLoad:(id)result {
    if ([request.method isEqualToString:@"facebook.fql.query"]) {
        NSArray* users = result;
        NSDictionary* user = [users objectAtIndex:0];
        NSString* name = [user objectForKey:@"name"];
        self.facebookName = name;       
        _logoutButton.hidden = NO;
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"FB_logged"];
        [_logoutButton setTitle:[NSString stringWithFormat:@"Facebook: Logout as %@", name] forState:UIControlStateNormal];
        /*if (_posting) {
         [self postToWall];
         _posting = NO;
         }*/
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:08:28+00:00Added an answer on May 26, 2026 at 11:08 pm

    Well for this you have to log in to FB only one time.
    Save the access token in your NSUserDefaults.
    Then when ever you want to share on FB just access your NSUserDefaults and get the access token and use that token for sharing.

    for storing the access token in NSUserDefaults

          facebook = [[Facebook alloc] initWithAppId:@"YOUR_APP_ID" andDelegate:self];
          NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:@"FBAccessTokenKey"] 
        && [defaults objectForKey:@"FBExpirationDateKey"]) {
        facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
        facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
    

    }

    below are the couple of links that will guide you

    https://developers.facebook.com/docs/mobile/ios/build/

    http://coffeeshopped.com/2011/01/saving-sessions-with-the-facebook-ios-sdk

    discussion on SO

    Saving Facebook access_token in NSUserDefaults on iOS

    How to get a Facebook access token on iOS

    To posting code that will go to you button press will be this:-

            FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
            dialog.userMessagePrompt = @"Enter your message:";
           dialog.attachment = [NSString stringWithFormat:@"I Love iOS"];
            [dialog show];
    

    here is the reference link.

    http://www.raywenderlich.com/77/how-to-post-on-facebook-with-your-iphone-app

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a reader application,which can sync text to googledoc,i got the working
Ha ii ,i am doing a reader application which have chapters in it,i have
Ha ii everybody i am doing a reader application which has so many functionality
I have a .net application which runs in the region of 20 to 30
I have a frame control in a WPF app which has an HTML page
I do have couple of solutions(rather call them hacks) for doing this but looking
now I am doing an Android application.I have to read a file from sdcard.I
I have a web application which among other things contains a table of items
In my application I currently have the ability to create a user which then
I want to use an access card reader with PHP. I am doing this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.