Shyam Bhat
Shyam Bhat

Reputation: 1600

posting UIImage to facebook along with other text

i'm trying to post an image on facebook using the following code.

FBStreamDialog* dialog ;
        if([FBSession session].isConnected)
            dialog = [[[FBStreamDialog alloc] initWithSession:[FBSession session]] autorelease]; 
        else
            dialog = [[[FBStreamDialog alloc] initWithSession:session] autorelease];

            dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@\",\"media\":[{\"type\":\"image\",\"src\":\"%@\"}]}", strEventStatus,eventImg];                

        [dialog show];

Does the media tag have any other property apart from src which would take and image in form of NSData? how do i post the image otherwise?

Upvotes: 0

Views: 991

Answers (3)

Nick Cartwright
Nick Cartwright

Reputation: 8254

I have no knowledge of the Facebook API you are using, but it would seem Image SRC would imply that the image is already somewhere on the web.

Have you considered uploading the image to a server somewhere and using the SRC of the image as a URL?

Upvotes: 0

user736596
user736596

Reputation: 1

You can directly take a UIimage and upload via the code used by BuildSucceeded, you no longer need to forward the image to a server and link via URL. You can also call the image from a UIimageview, camera or library.

Upvotes: 0

ipraba
ipraba

Reputation: 16543

While you are linking the attachment property for a Image the source should be a URL.. I dont think You can post a UIImage by using attachment.. One solution is you can have a webservice for posting the image in your server and then give that URL when you are posting.

I dont know which Facebook API you are using.. This what i did to upload a image by using Facebook Graph API

  UIImage *img  = [UIImage imageNamed:@"myImage.png"];

  NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                 img, @"picture",
                                 nil];
  //facebook is a facebook Obj which I initialized before
  [facebook requestWithMethodName:@"photos.upload"
                         andParams:params
                     andHttpMethod:@"POST"
                       andDelegate:self];

Upvotes: 1

Related Questions