Upload image to facebook using default dialog - ios

I'm trying to upload an image to facebook using the iOS SDK from Facebook.
To upload an image, I'm doing following:
-Upload image to a private server in order to get the image URL.
-Open facebook dialog with "feed" in order to upload a comment to facebook wall.
My goal is to avoid using a private server to upload the picture and get the URL, in order to upload the image to facebook directly from iPhone.
I've been googling and I found several solutions to upload images directly to facebook, but is without using the default dialog that includes the SDK.
Is any way to upload images directly from device, using the FB dialog object? Is not an option for me to make the Views to replace the dialog.
Thanks in advance.
As far this is my code to publish on facebook:
+(void)composeFacebookWithImageUrl:(NSString *)imageURL image:(UIImage *)image delegate:(id)delegate
{
Facebook *_facebook;
_facebook = [[[Facebook alloc] initWithAppId:kAppId andDelegate:delegate] autorelease];
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
#"Always Running",#"text",#"http://itsti.me/",#"href", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
#"Ragdoll", #"name",
#"The Ragdoll maker app", #"caption",
#"Share with your friends", #"description",
#"http://www.im2.es/", #"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Share on Facebook", #"user_message_prompt",
actionLinksStr, #"action_links",
attachmentStr, #"attachment",
#"touch",#"display",
imageURL, #"picture",
nil];
[_facebook dialog:#"feed"
andParams:params
andDelegate:delegate];
}
Thanks.

Have you looked into ShareKit? I'm using it to share images in my apps and it works great.
https://github.com/ShareKit/ShareKit

Related

iOS Post to Facebook shows m.facebook.com

My iOS app is posting an in-app post of ours from our app to Facebook using the Social framework and the following code.
It successfully posts to Facebook and correctly deep-links back into our application. The issue is that when this post is viewed on the Facebook iOS mobile app, instead of displaying the post's caption or description, we are seeing "m.facebook.com" as shown in this screenshot. We'd like to remove or replace "m.facebook.com" with either caption, description, or our site's root URL.
I"m guessing this "m.facebook.com" URL root is coming from the deep link URL, which is "https://m.facebook.com/apps/(our-app)/?deeplink=postId:(post-id)". We want it to deep link, but don't want "m.facebook.com" to be displayed.
Any advice? Thanks.
NSString *deepLink = [NSString stringWithFormat:#"https://m.facebook.com/apps/%#/?deeplink=postId:%i",FACEBOOK_APP_NAMESPACE,self.post.postId.intValue];
captionString = [NSString stringWithFormat:#"%# : %#", parentCategory.name, category.name];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
self.post.name, #"name",
captionString, #"caption",
self.post.details, #"description",
deepLink, #"link",
nil];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:feedURL
parameters:params];

Facebook feed dialog , post to wall , caption out off frame

i am using newest Facebook SDK from https://github.com/facebook/facebook-ios-sdk
and trying use feed dialog to Post to wall , the caption are out off the dialog frame.
it missing some word so i can't read whole caption, like this:
http://www.freeimagehosting.net/66oyf (sorry i can't post image on stack overflow yet since my reputation is too low.)
here is the code:
NSMutableDictionary *param = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[Utility getFBIconUrlHref], #"link",
[Utility getFBIconUrlSrc], #"picture",
name, #"name",
_bookName, #"caption",
#"description" , #"description", nil];
[_fb dialog: #"feed"
andParams: param
andDelegate:self];

Add Image to Facebook Wall

I am trying to implement a previous answer. Here is the code recommended:
-(void) postImageToFB:(UIImage *) image
{
NSData* imageData = UIImageJPEGRepresentation(image, 90);
Facebook* fb = [(uploadPicAppDelegate *)[[UIApplication sharedApplication] delegate] facebook ];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:[fb accessToken],#"access_token",
#"message text", #"message",
imageData, #"source",
nil];
[fb requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
}
But I am getting a error not found on the term: uploadPicAppDelegate
I can't find this in the Facebook sdk or a search of the web (other than additional similar code). Is this a custom created data type --or -- am I missing a file that needs to be imported?
Thanks.
In your params dictionary the value for #"source" should be a link for the picture and not a NSData object.

Adding a share link when using fbdialog to post to a users wall

I'm using FBConnect to post a link to a user's wall. I am using the FBDialog api instead of using graph paths:
[facebook dialog:#"feed" andParams:_params andDelegate:_delegate];
Everything posts correctly except when the wall is viewed, there is no share link, only the like and comment links. I've researched this and figured out that this appears to be unique to using FBDialog.
If the graph path method is used:
[facebook requestWithGraphPath:_path andParams:_params andHttpMethod:#"POST" andDelegate:_delegate];
the share link shows up.
To fix this, I have added a custom link using the actions parameter provided by FBDialog:
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* actionLinks = [NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
#"Share", #"name",
#"http:???", #"link",
nil],
nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
[params setObject:#"link" forKey:#"type"];
[params setObject:self.url forKey:#"link"];
[params setObject:self.title forKey:#"name"];
[params setObject:self.caption forKey:#"caption"];
[params setObject:actionLinksStr forKey:#"actions"];
This again, works correctly and creates a share link. The question I have is: What url do I use to share the wall post? Any ideas?
Thanks so much!

I've problem with Facebook SDK for iOS

NSLog(#"%#",selectedImage);
if (self.selectedImage != nil) {
UIImage *img = self.selectedImage;
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, #"picture",
#"iOS Apps with FBConnect",#"caption",
nil];
[facebook requestWithGraphPath:#"me/photos/Wall"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
[img release];
}
I've this code.,
I use Facebook graph API for post photo to my wall.
but Photo has been upload to other album
Can I select album to upload photo ??
or
I'd like my photo upload into "Wall Photos" album ??

Resources