How to add a picture to FBWebDialogs, using Facebook SDK 3.2 - objective-c

I am using the FBWebDialogs view for posting a message on your wall. This functionality is added to Facebook SDK 3.2
I am creating a multiplayer board game, and game invitations can be posted to your friends wall.
No I'd like to add a picture as well, the app logo.
The only thing I got working is the following:
NSMutableDictionary *params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Krudoku for iPhone, iPad and iPod touch", #"name",
FBopponent.FBid, #"to",
#"A multiplayer game which is a mixture of scrabble and sudoku.", #"caption",
#"I'd like to play a game of Krudoku with you. Please go to the appstore and download Krudoku so we can play together!", #"description",
#"http://www.facebook.com/Krudoku", #"link",
#"http://www.krudoku.com/pictures/appicon_fb_136.png", #"picture",
nil];
// Invoke the dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
....
....
}];
The picture parameter refers to a picture on my web server. Now I would like to refer to a picture being saved on local device. But things like #"file://...." are not working.
Can anyone help me out here?

You must upload the picture to a web server and then using URL where you can access the uploaded picture, e.g.
http://www.myserver.com/uploads/myPicture.png
See also this question.

Related

Posting from my app in Facebook

I would like to update my iOS app to take advantage of iOS 6 Facebook integration. Currently I use the Facebook dialogue. I like the way I can present the dialogue to the user and when it posts it has my app icon and the small tag saying "via my app name" which links to my app.
With the iOS 6 Facebook integration it says "via iOS" and a link to Apple's Website. Is there a way to achieve the same type of result using iOS 6's Facebook integration?
current code:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"1234567890", #"app_id",
#"http://www.mywebsite.com/page5/page5.html", #"link",
picLink, #"picture",
countDownName, #"name",
#"My app name", #"caption",
#"For the iPhone and iPod Touch", #"description",
theMessage, #"message",
theFriendID, #"to",
#"Share on Facebook", #"user_message_prompt",
nil];
[facebook dialog:#"feed" andParams:params andDelegate:self];
my iOS 6 code (taken from Facebook's sample code)
BOOL displayedNativeDialog = [FBNativeDialogs presentShareDialogModallyFrom:self
initialText:initialText
image: [UIImage imageNamed: #"myImage.png"]
url:url
handler:nil];
if (!displayedNativeDialog) {
[self performPublishAction:^{
// otherwise fall back on a request for permissions and a direct post
[FBRequestConnection startForPostStatusUpdate:message
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
[self showAlert:message result:result error:error];
self.buttonPostStatus.enabled = YES;
}];
self.buttonPostStatus.enabled = NO;
}];
A quick google search showed the following tutorial: http://www.techotopia.com/index.php/IPhone_iOS_6_Facebook_and_Twitter_Integration_using_SLRequest#Facebook_Integration_using_SLRequest
That seems to be a good tutorial to do what you're looking for.
Please try using custom Facebook compose view provided here.

How to get share dialog box with parse.com and facebook 3.0 sdk

I can't seem to find information on how to open share dialog box with parse sdk which includes fb 3.0. I am able to login with facebook and actually found a way to post with out the dialog box but still would like to have the dialog box so that people can add comments and it comes out with the image on facebook. This is what i have so far.
#"publish_stream",#"publish_actions" allows me to publish with out the dialog box
logInController.facebookPermissions = [NSArray arrayWithObjects:#"user_about_me",#"friends_about_me",#"publish_stream",#"publish_actions", nil];
this is to publish
PF_FBRequest *request = [PF_FBRequest requestForPostStatusUpdate:[self.Excerpt objectForKey:#"text"]];
[request startWithCompletionHandler:^(PF_FBRequestConnection *connection, id result, NSError *error){
NSLog(#"error %#",error);
}];
I found the code to open the dialog box from facebook website but i am not sure how to get an instance of the PF_Facebook object so i can open the dialog box. I can try to do
PF_Facebook *fb = [[PF_Facebook alloc]initWithAppId:<#(NSString *)#> andDelegate:<#(id<PF_FBSessionDelegate>)#>;
but that doesn't seem to be right because i already initialize this in the appdelegate
//Update
I am able to get the dialog box using this code
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Facebook SDK for iOS", #"name",
#"Build great social apps and get more installs.", #"caption",
#"The Facebook SDK for iOS makes it easier and faster to develop Facebook integrated iOS apps.", #"description",
#"https://developers.facebook.com/ios", #"link",
#"https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png", #"picture",
nil];
//publishes text on facebook
PF_FBSession *session = [PFFacebookUtils session];
PF_Facebook *fb = [[PF_Facebook alloc]initWithAppId:session.appID andDelegate:nil];
[fb dialog:#"feed" andParams:params andDelegate:self];
But the problem is that the person gets the login page in the dialog box even though he is authenticated already in the app
Any suggestions would be greatly appreciated!
Thank You!
To set up a PF_Facebook object you need to also provide the access token and expiration date information as below:
PF_FBSession *session = [PFFacebookUtils session];
PF_Facebook *facebook = [[PF_Facebook alloc] initWithAppId:session.appID
andDelegate:nil];
// Store the Facebook session information
facebook.accessToken = session.accessToken;
facebook.expirationDate = session.expirationDate;
Rather than creating a new session, you can just use the "facebook" class method to get a configured PF_Facebook object
PF_Facebook *facebook = [PFFacebookUtils facebook];
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"Check out this great app", #"message", nil]:
[facebook dialog:#"apprequests" andParams:parameters andDelegate:nil];

iOS5 and Facebook SDK 3.01/Facebook feed

I'm going crazy. I've installed the Facebook SDK 3.01. I've added it to my frameworks. I've imported it into my view controller. I'm using the code from the Facebook developers' page, as follows:
UIImage *pic = [self createImage];
NSString *list = self.haiku_text.text;
NSString *kAppId=#"xxxxxxxxx0507";
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:kAppId, #"app_id",nil, #"link", pic, #"picture",#"Haiku", #"name",nil, #"caption",#"Maybe he'll love me if I give him a haiku....",#"description",nil];
[facebook dialog:#"feed"
andParams:params
andDelegate:self];
And no matter what I do I get a use of undeclared identifier 'facebook' error. This suggests to me that facebook needs to be an instantiation of some class or property--but I've been looking for what feels like millennia and I can't find out anywhere what that class or property is. What I've read on stackoverflow makes me think it used to have something to do with FBConnect, but that doesn't seem to exist in the new Facebook SDK.
Any thoughts that will help me keep at least a little of the hair I'm tearing out?

Cancel image upload to Facebook from iOS

I have an app that uploads an image to Facebook. this is the part of my code that does that:
[[self appDelegate] facebooking]; // checke that the user is loged in
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
labeledImage, #"source",
FB_IMG_POST_TITLE,#"message",
nil];
[ [[self appDelegate] getFacebookVar] requestWithGraphPath:[NSString stringWithFormat: #"/me/photos?access_token=%#", self.appDelegate.getFacebookVar.accessToken] andParams:params andHttpMethod:#"POST" andDelegate:self];
I want to
A) make the upload process a different thread.
B) Give the user the option to cancel the upload.
How would I do that?
Firstly, you are not using the facebook SDK correctly. You should not need to explicitly add the access_token. Please see the sample code for this.
You shouldn't need a different thread, the request will be handled asynchronously. What made you think you need to do this?
I'm not sure you can do B) by default. You could change the sdk source to give access to the NSURLConnection (which you can cancel).

Post to Friend's Wall with iOS Facebook SDK

Is it possible to use the iOS Facebook SDK's dialog method to post to the active user's friends' walls? That is, assuming the correct permissions have been granted?
Using the dialog method, with "feed" as the action, only seems to allow me to post to the user's stream, not to anyone elses. What am I missing?
[facebook dialog:"feed" andParams:... andDelegate:self]
The params only specify the content of the post; there doesn't seem to be any way to specify the profile I want to post to.
Just use the following code:
[facebook requestWithGraphPath:#"[IdOfFriend]/feed" andParams:... andHttpMethod:#"POST" andDelegate:self];
post on friends wall through graph path no more works
your feed action works.. have params like
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Checkout my APP_NAME", #"name",
#"Come visit my APP_NAME", #"caption",
[NSString stringWithFormat:#"I just joined APP_NAME Can you?"], #"description",
#"http://www.friendsmash.com/images/logo_large.jpg", #"picture",
#"FRIEND'S_FB_USER_ID", #"to",
// Add the link param for Deep Linking
[NSString stringWithFormat:#"https://YOUR_WEB_LINK.com/"], #"link",
nil];
Cheers...!