Share image from bundle and link on Facebook in iphone - 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];

Related

Facebook share passs link in app name

I want to pass a link in App Name for example if user click on text via (App Name) then it navigate some specific url
If anybody can help my code is here:
Facebook *fb = [[Facebook alloc] initWithAppId:FB_ID andDelegate:self];
NSString *strUrl = [dicItemDetails valueForKey:#"imgurl"];
if ([strUrl length] == 0) {
strUrl = [[temp objectAtIndex:0] valueForKey:#"logourl"];
}
NSMutableDictionary *d = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
[dicItemDetails valueForKey:#"menuItemName"], #"name"
, strCaption,#"description"
, strUrl, #"picture"
, [[temp objectAtIndex:0] valueForKey:#"facebook"], #"link"
, nil];
[fb dialog:#"feed" andParams:d andDelegate:self];
you can post two link with your Message posting in facebook time line like bellow way:-
-(void)fbNewuserWallpost
{
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSArray* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
#"AppName",#"name",self.FirstLinkString,#"link", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"yourAppID",#"app_id",
#"AppName", #"name",
captonString, #"caption",
#"yourDiscription", #"description",
self.secondLinkString, #"link",
#"ImageURL", #"picture",
actionLinksStr, #"actions",
nil];
[[AppDelegate facebook] requestWithGraphPath:#"me/feed" 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

Facebook integration showing alert address is invalid

I am new in iPhone application development. Now i am developing application for iPhone In this application I need to upload video to Facebook. i am used below code. Now enter Facebook the user name and password. showing error message alert. like safari cannot open the page because the address is invalid.
- (void)viewDidLoad
{
facebook = [[Facebook alloc] initWithAppId:#"Facebook_App_Id"];
//#"com.facebook.samples.VideoUploadTest"];
facebook.sessionDelegate = self;
}
- (IBAction)buttonClicked:(id)sender {
NSArray* permissions = [[NSArray alloc] initWithObjects:
#"publish_stream", nil];
[facebook authorize:permissions delegate:self];
[permissions release];
}
- (void)fbDidLogin {
NSString *filePath = [[NSBundle mainBundle] pathForResource:#"sample" ofType:#"mov"];
NSData *videoData = [NSData dataWithContentsOfFile:filePath];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
videoData, #"video.mov",
#"video/quicktime", #"contentType",
#"Video Test Title", #"title",
#"Video Test Description", #"description",
nil];
[facebook requestWithGraphPath:#"me/videos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
}
referred from this url [http://developers.facebook.com/blog/post/532/]
Refer this for SSO settings.
http://developers.facebook.com/docs/mobile/ios/build/

Framework for uploading images with titles to Facebook

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

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