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 6150049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:33:24+00:00 2026-05-23T19:33:24+00:00

I’d be grateful for any suggestions as to how to deal with a problem

  • 0

I’d be grateful for any suggestions as to how to deal with a problem I’m having posting an image to Facebook.

The following code works just as I would expect:

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                 @"http://myserver/img.png", @"picture",
                 @"My Testing", @"name",
                 @"Enter some text...",  @"message",
                 nil];

[appDelegate.facebook dialog:@"feed" andParams:params andDelegate:self];

However, I really want to use an image that I capture from my camera. I’ve set up the code to do that earlier in my application and I’ve put the image on the screen. So, I tried to do this:

CGRect contextRect  = CGRectMake(0, 0, 320, 436);
UIGraphicsBeginImageContextWithOptions(contextRect.size, YES, 1);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

I’ve tested this code and newImage is a valid UIImage that I can place and manipulate just as I’d expect. However, when I try to integrate it into the Facebook dialog as follows:

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                 newImage, @"picture",
                 @"My Testing", @"name",
                 @"Enter some text...",  @"message",
                 nil];

[appDelegate.facebook dialog:@"feed" andParams:params andDelegate:self];

I get these two ridiculous messages in the console:
-[UIImage length]: unrecognized selector sent to instance 0x1c9420
CoreAnimation: ignoring exception: -[UIImage length]: unrecognized selector sent to instance 0x1c9420

So, as a test, I thought I’d try importing an image into my project and accessing it directly. This is the exact image as I referenced online in the first example, so I know it should work. But even when I try this:

UIImage *newImage = [UIImage imageNamed:@"BaB.png"];

I get the same error messages as above.

I see in the Facebook documentation that the “picture” key is supposed to use the URL to an image. But I’ve seen some examples online that indicate that folks are using an UIImage instead of just an URL.

Clearly, I’m doing something wrong, but I have no idea what it might be.

I’d be very grateful for any pointers as to how to proceed.

  • 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-23T19:33:24+00:00Added an answer on May 23, 2026 at 7:33 pm

    A summarized answer that outlines the process…key point is to include the access_token in the graph calls since the facebook-ios-sdk doesn’t do this automatically:

    1)Update to the latest facebook-ios-sdk.
    2)Instantiate with app id.

    
    
          self.facebook = [[Facebook alloc] initWithAppId:kApplicationFBID]; 
    
    

    3) Authorize the app including publish_stream

    
    
      NSArray * neededPermissions = [[[NSArray alloc] initWithObjects:@"user_about_me", @"publish_stream", @"user_photos", nil] autorelease];
      [facebook authorize:neededPermissions delegate:appDelegate];
    
    

    4) Ensure app delegate fBDidLogin captures and stores the access token & expiration in user defaults (for later optimization of login process).

    
    
        -(void)fbDidLogin {
            DebugLog(@"New Access Token: %@", [facebook accessToken] );
            NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
            [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
            [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
            [defaults synchronize];
        }
    
    

    5) Confirm valid access token (non nil and not expired)…otherwise re authorize app per above.
    6) Capture image to UIImage & call this noting the critical addition of the access_token. This will auto create an album for your app and put the image there and post it on the wall per my testing.

    -(void)postImageToAlbum:(UIImage *)image {
      NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
        image, @"source", 
        @"caption desc", @"message",             
        nil];
      [facebook requestWithGraphPath:[NSString stringWithFormat:@"/me/photos?access_token=%@", self.facebook.accessToken]
      andParams:params andHttpMethod:@"POST" andDelegate:self];
    }
    

    7) Check for id result in FBRequestDelegate method

    
    
        -(void)request:(FBRequest *)request didLoad:(id)result {
            NSLog(@"Request didLoad: %@ ", [request url ]);
            if ([result isKindOfClass:[NSArray class]]) {
                result = [result objectAtIndex:0];
            }
            if ([result isKindOfClass:[NSDictionary class]]){
    
            }
            if ([result isKindOfClass:[NSData class]]) {
            }
            NSLog(@"request returns %@",result);
         }
    
    

    8) DO NOT USE a test user account for testing...currently it will auth the test account and provide an access token but when you try to use graph api it will return unexpected errors. You may be alright if you are using web version vs native app setting in dev.facebook.com since supposedly you can create test users and associate them with the app but I haven't tried that.

    Good Luck!

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

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.