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

  • SEARCH
  • Home
  • 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 7818637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:38:41+00:00 2026-06-02T06:38:41+00:00

I am trying to post an image to Facebook. Yesterday i got it, but

  • 0

I am trying to post an image to Facebook. Yesterday i got it, but today I tested it again and it doesn’t work :S. I can’t find the problem. I have modified some things but none of the methods that Facebook interacts with. I hope someone can help me.

I got everything in my viewController because it logs in only when the user requests.

I debugged it and only "publishFacebook" gets called, because i call it. It goes to Facebook and requests the permissions and then you return and nothing happens.

The URL Schemes are correct.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>fb235694579858240</string>
        </array>
    </dict>
</array>
</plist>

ViewController.h

import "FBConnect.h"

@interface ViewController : UIViewController <UIImagePickerControllerDelegate, UIActionSheetDelegate, UIGestureRecognizerDelegate, MFMailComposeViewControllerDelegate, FBSessionDelegate, FBDialogDelegate, FBRequestDelegate>

@property (nonatomic, retain) Facebook *facebook;
-(void)postWall;

ViewController.m

-(void) publishFacebook:(UIImage *)img { 
    
    //start the facebook action by clicking any button
    _publishedImage = img;
    _facebook = [[Facebook alloc] initWithAppId:@"235694579858240" andDelegate:self];
    
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) {
        _facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
        _facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
    }
    
    if (![_facebook isSessionValid]) {
        NSArray *permissions = [[NSArray alloc] initWithObjects:
                                @"user_photos",
                                @"user_likes", 
                                @"read_stream",
                                nil];
        _facebook.sessionDelegate = self;
        [_facebook authorize:permissions];
    }else{
        [self postWall];
    }
}
    
    
    - (void)fbDidLogin {
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        [defaults setObject:[_facebook accessToken] forKey:@"FBAccessTokenKey"];
        [defaults setObject:[_facebook expirationDate] forKey:@"FBExpirationDateKey"];
        [defaults synchronize];
        [self postWall];
    }
    
    - (void)postWall{
        
        //NSString *filePath = [[NSBundle mainBundle] pathForResource:@"image" ofType:@"png"];
        NSData *imageData = UIImagePNGRepresentation(_publishedImage);
        //[NSData dataWithContentsOfFile:filePath]
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                       @"Check out my awesome image!. I make it with Trolling for iOS", @"message", imageData, @"source", nil];
        [_facebook requestWithGraphPath:@"me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self];
        
        NSLog(@"Image posted");
        
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Image Posted" message:@"Your image was successfully posted of facebook" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
        [alertView show];
    }
    
    -(void)fbDidNotLogin:(BOOL)cancelled{
        if (cancelled) {
            UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"Could not Login" message:@"Facebook Cannot login please try again" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles: nil];
            [alertView show];
        }
    }


- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return [_facebook handleOpenURL:url];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return [_facebook handleOpenURL:url]; 
} 

Thanks

  • 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-06-02T06:38:44+00:00Added an answer on June 2, 2026 at 6:38 am

    You need to carefully follow Facebook’s tutorial and everything should work: developers.facebook.com/docs/mobile/ios/build

    The only adjustment you need is to fire the login process as a result of the UIButton IBAction call. The rest is exactly the same flow. This is quite a delicate process and is very hard to debug if you miss something out.

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

Sidebar

Related Questions

I am trying to post image on facebook but not successful yet, my codes
I am trying to post an image to a Facebook album using a form
i'm trying to post an image to my users's facebook wall once they hit
I am trying to post an image to facebook grap api using asp.net ,
I can't post the exact data i'm trying to extract but here's a basic
I am trying to post an image to an album on facebook and place
I am trying to receive the url image and post the image into base64
I'm trying to convert the following CURL: curl -X POST \ -H Content-Type: image/jpeg
I have been trying to post a photo on facebook using facebook graph API.
I'm trying to post a graph object on my facebook timeline, the title and

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.