Framework for uploading images with titles to Facebook - iphone

I see in the internet codes that do upload images but the use "Facebook" that isn't recognized, so which framework do I need to use in iOS?
Do you have a code example?
I found this code:
- (IBAction)uploadPhoto:(id)sender {
NSString *path = #"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:img, #"picture", #"my photo's caption text here.", #"message", nil];
[facebook requestWithMethodName: #"photos.upload" andParams:params andHttpMethod:#"POST" andDelegate:self];
[img release];
}

You'll need to add the Facebook iOS SDK to your project.
All the details you need should be found here

Related

Share image from bundle and link on Facebook in iphone

I want to share image,link etc to Facebook from my iphone app.My app Link,cation,name and description posted successfully. But i can't share image. Please follow my code..
UIImage *image = [UIImage imageNamed:#"sample.png"];
NSData *imgData = UIImageJPEGRepresentation(image, 1.0);
self.dictionary =[[NSMutableDictionary alloc] initWithObjectsAndKeys: #"https://www.google.com/ios", #"link",
imgData, #"data",
#"AppName", #"name",
#"Testing", #"caption",
#"say something about this", #"description",
nil];
my share facebook code is..
[facebook requestWithGraphPath:#"/me/feed" andParams:dictionary andHttpMethod:#"POST" andDelegate:self];
My problem is how to take image from bundle and how to share selected image to Facebook?Please help me..
use like below:
NSString *filePath = [[NSBundle mainBundle] pathForResource:#"image1" ofType:#"png"];
NSData *videoData = [NSData dataWithContentsOfFile:filePath];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"My hat image", #"message", data, #"source", nil];
[facebook requestWithGraphPath:#"/me/photos" andParams:params andHttpMethod:#"POST" andDelegate:self];

How To upload Video on Facebook using FBConncet?

In my application i am trying to upload Video on facebook wall using FbConnect my Code looks oky But i Don't know why my Video is not uploaded Beacuse if i use the Same Code method for Uploading image it successfully upload the image on facebook.here is my code which i use for image uploading
NSString *filePath = [[NSBundle mainBundle] pathForResource:#"2" ofType:#"png"];
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfFile:filePath];
UIImage *img = [[UIImage alloc] initWithData:data];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, #"Picture",
nil];
[_facebook requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
[img release];
And for Video i am trying this Code so For
NSString *filePath = [[NSBundle mainBundle] pathForResource:#"myVideo" ofType:#"mp4"];
NSURL *url = [NSURL URLWithString:filePath];
NSData *videoData = [NSData dataWithContentsOfURL:url];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
videoData, #"video.mp4",
#"video/quicktime", #"contentType",
#"Video Test Title", #"title",
#"Video Test Description", #"description",
nil];
[_facebook requestWithGraphPath:#"me/videos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
The Above code give me no error but it retun some text msg in label (the operation Could not be completed).Which is not in case of image uploading.So can some guide me how to fix it.Thanks
Try these lines:
NSString *filePath = [[NSBundle mainBundle] pathForResource:#"myVideo" ofType:#"mp4"];
NSData *videoData = [NSData dataWithContentsOfFile:filePath];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
videoData, #"video.mp4",
#"video/quicktime", #"contentType",
#"Video Test Title", #"title",
#"Video Test Description", #"description",
nil];
[_facebook requestWithGraphPath:#"me/videos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
Hope this help you.its working fine for me.Now add these lines.
http://stackoverflow.com/questions/10509984/how-to-upload-mp4-video-on-facebook-using-graph-api-in-objective-c
http://%5B1%5D:%20https://github.com/reallylongaddress/iPhone-Facebook-Graph-API
http://stackoverflow.com/questions/12861615/upload-video-to-facebook-using-facebook-new-sdk-on-ios-6-0

How to upload multiple images to facebook from iphone sdk

i want to upload Multiple images to Facebook from iphone. And i have search so many things and made a code as below: but it's not working. Any help will be appreciated.
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSString *jsonRequest1 = #"{ \"method\": \"POST\", \"relative_url\": \"me/photos\" , \"body\": \"Hello 1\", \"attached_files\": \"file1\" }";
NSString *jsonRequest2 = #"{ \"method\": \"POST\", \"relative_url\": \"me/photos\" , \"body\": \"Hello 2\", \"attached_files\": \"file2\" }";
NSString *jsonRequestsArray = [NSString stringWithFormat:#"[ %#, %# ]", jsonRequest1, jsonRequest2];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:jsonRequestsArray,#"batch",nil];
NSString *url1=#"http://uhallnyu.files.wordpress.com/2011/11/green-apple.jpg";
NSString *url2=#"http://scm-l3.technorati.com/12/04/24/67277/apple.gif?t=20120424140104";
NSData *data1 = [NSData dataWithContentsOfURL:[NSURL URLWithString:url1]];
UIImage *img1 = [[UIImage alloc] initWithData:data1];
NSData *data2 = [NSData dataWithContentsOfURL:[NSURL URLWithString:url2]];
UIImage *img2 = [[UIImage alloc] initWithData:data2];
[params setObject:img1 forKey:#"file1"];
[params setObject:img2 forKey:#"file2"];
[[delegate facebook] requestWithGraphPath:#"me/feed" andParams:params andHttpMethod:#"POST" andDelegate:self];
You can upload photos to facebook using :-
You can have a switch case to read the type of image from your image file and get imagedata using functions UIImagePNGRepresentation,UIImageJPEGRepresentation,etc.
NSData *yourImageData= UIImagePNGRepresentation(yourImage);
Initialize the dictionary :-
NSMutableDictionary *mutableDictWithParam= [NSMutableDictionary dictionaryWithObjectsAndKeys:#"Your text", #"message", yourImageWithData, #"theSource", nil];
finally send post :-
[facebook requestWithGraphPath:#"/me/photos" andParams:mutableDictWithParam andHttpMethod:#"POST" andDelegate:self];
You can have it in loop to send more than one image.

How to upload .mp4 video on facebook using graph api in objective c

I am using Graph API to upload video on facebook. I am able to upload .wmv format video but not .mp4. My code is as below
strVidUrl=#"http://myshow.com.au/Videos/mp4s/20111216044530271247467.mp4";
//strVidUrl=#"http://www.myshow.com.au/Videos/BossAlarm.wmv";
NSURL *url = [NSURL URLWithString:strVidUrl];
NSData *data = [NSData dataWithContentsOfURL:url];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
data, #"video.mov",
#"video/mp4", #"contentType",
[dicVideoDetails valueForKey:#"fld_display_name"], #"title",
[dicVideoDetails valueForKey:#"fld_video_description"], #"description",
nil];
if I use .wmv then code is below and it is running.
NSURL *url = [NSURL URLWithString:#"http://www.myshow.com.au/Videos/BossAlarm.wmv"];
NSData *data = [NSData dataWithContentsOfURL:url];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
data, #"video.mov",
#"video/quicktime", #"contentType",
#"Video Test Title", #"title",
#"Video Test Description", #"description",
nil];
Result is comming same in both cases but .mp4 video is not showing on facebook. while .wmv is showing there.
Please help me.
That may be due to the missmatch of codecs and compression rates of your source video and fb's recomented video format
Check the following Links
Upload Video on facebook
demo
Regards,
Let me know in case of queries.

upload image on facebook ios

please help me to upload image on facebook using iphone app.here i dont have the url.i just only have the image.but i cant upload it on face book.if i can use an url then i can simply upload it.please help me.
please send me the code for upload image.
i already create facebook instance and other codes relative to fbconnect ios.
The DemoApp that comes with the facebook ios api contains the code to upload a photo in the sample:
https://github.com/facebook/facebook-ios-sdk/tree/master/sample/DemoApp
/**
* Upload a photo.
*/
- (IBAction)uploadPhoto:(id)sender {
NSString *path = #"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, #"picture",
nil];
[_facebook requestWithMethodName:#"photos.upload"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
[img release];
}