posting UIImage to facebook along with other text - iphone

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?

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];

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?
I hope this helps!

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.

Related

Facebook Photo Size in iOS sdk

Right now with the Facebook iOS sdk, I am pulling images off the wall. but I need to analyze the photo and determine the height and width of the photo.
How would I go about doing this?
I know that this is an old question which has been answered, but since the accepted answer is very unclear and because this might help others that have the same problem as you had:
Given that the images that you pull off the wall are turned into UIImage objects before you display them, then you can just do the following to easily get the height and width of each object:
Full code example:
NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:yourimageurlhere]];
UIImage* image = [[[UIImage alloc] initWithData:imageData] autorelease];
[imageData release];
NSLog(#"Height : %0.1f", image.size.height);
NSLog(#"Width : %0.1f", image.size.width);
when you issue a call to GraphAPI photo object, you get dimensions in the response: https://graph.facebook.com/98423808305
is it what are you looking for?

How to take a picture and send it as an email attachment in iOS

Currently, I can set a button to take a picture, but I'm unsure how to pass this as an attachment for an email in the same view.
The view is for a quote and allows the user to enter data into a few fields then has a button to email said data.
Maybe this link would satisfy your requirement for the second half of the question...
http://www.ericd.net/2009/04/sending-email-from-iphone-application.html
UIImage *myImage = [UIImage imageNamed:#"mobiletuts-logo.png"];
NSData *imageData = UIImagePNGRepresentation(myImage);
[mailer addAttachmentData:imageData mimeType:#"image/png" fileName:#"mobiletutsImage"];
Courtesy:
http://mobile.tutsplus.com/tutorials/iphone/mfmailcomposeviewcontroller/
Check out Apple's MailComposer example http://developer.apple.com/library/ios/#samplecode/MailComposer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008865

How to implement sharing via Twitter, mail & Tumblr using ShareKit

I am trying to use ShareKit to implement sharing via Twitter, mail & Tumbler but I am unable to make them work correctly.
I implemented the following code on view load,
SHKItem *item;
item=[SHKItem image:[UIImage imageNamed:#"icon2.png"] title:#"Praveen"];
[SHKFacebook shareItem:item];
Please help me..
Try these following lines ;) it works for me :)
NSString *imageName=[NSString stringWithFormat:#"marriage0.jpg"];
NSString *message=[NSString stringWithFormat:#"%#",self.myMessage.text];
UIImage *image =[UIImage imageNamed:imageName];
SHKItem *fbItem = [SHKItem image:image title:message];
[SHKFacebook shareItem:fbItem];

Uploading pictures to Facebook

I am writing an app that publishes pictures on Facebook using facebook-ios-sdk, but everytime I upload a picture, it's displayed with the wrong orientation on my album. Here's the code I am using, note that I account for the orientation on the second line:
ALAssetRepresentation *rep = [currentAsset defaultRepresentation];
UIImage *img = [UIImage imageWithCGImage:[rep fullResolutionImage] scale:[rep scale] orientation:[rep orientation]];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, #"picture",
[pictureCaptionTextView text], #"caption",
nil];
[facebook requestWithMethodName: #"photos.upload"
andParams: params
andHttpMethod: #"POST"
andDelegate: self];
[img release];
Does anyone know what's going on? Should I pass the orientation when uploading it?
Have you tried using different photos, or are you testing on the same images each time? Sometimes an image will have EXIF data that will tell image programs to rotate it; it could be either that facebook is honoring EXIF data that your local app isn't and thus rotating or it could be that locally your program is displaying it rotated and facebook isn't.
Try viewing your photo in a few different browsers, and even better try downloading a photo from facebook and then re-uploading it =]
I finally figure this out thanks to this link.
The trick is that UIImageView automatically rotates the image correctly but the raw data is always on the default camera orientation (landscape, top to the right), so you need to adjust accordingly.
Bonus: this method resizes the image if you need to.

Sharing Youtube video to Facebook using FBStreamDialog

I am developing an iPad application in which I need to share a Youtube video link to Facebook.
I am using FBStreamDialog for image sharing as follows:
But, I do not know how to share the video (I wanted to know about the parameters like media type, src, href etc)
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.targetId = <facebookUserId?;
dialog.userMessagePrompt = #"What's in your mind?";
dialog.attachment = #"{\"name\":\"Sample Photo\","
"\"href\":\"http://abstract.desktopnexus.com/wallpaper/250923\","
"\"caption\":\"MyAppName\",\"description\":\"Testing share\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"http://static.desktopnexus.com/wallpapers/250923-bigthumbnail.jpg\","
"\"href\":\"http://abstract.desktopnexus.com/wallpaper/250923\"}],"
"\"properties\":{\"another link\":{\"text\":\"Facebook home page\",\"href\":\"http://www.facebook.com\"}}}"
[dialog show];
Could someone help me?
Thanks and Regards,
Deepa
I have explained here all the Facebook Meta tags which are used for sharing.
You can have a look at this post, it may be useful.