iOS5 and Facebook SDK 3.01/Facebook feed - objective-c

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?

Related

How to add a picture to FBWebDialogs, using Facebook SDK 3.2

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.

Passing a Facebook Places id, from placesPicker in iOS... to postParams for a feed publish

This has been driving me bananas! I'm trying to get my app to publish a message to the users facebook feed, and a checkin to a facebook Place after selecting a local place from the placesPicker in iOS.
I've pretty much got everything working in testing, meaning when I just hand type string values for all the postParams for the NSMutableDictionary, it posts perfectly. ex:
self.postParams =
[[NSMutableDictionary alloc] initWithObjectsAndKeys:
#"I am doing XYZ", #"message",
#"123456abc",#"tags",
#"123456xyz,#"place",
nil];
The above postParams work perfectly when published to feed, it displays the message, then checks in to the "place" id and says you are with the userid in "tags". The problem is that I am really getting the Place id from the Facebook SDK's placePicker. I've got the picker setup and working perfectly, but I can not figure out how to replace the hardcoded #"123456xyz" with the id from the picked Place.
this is currently what I have in there now:
self.postParams =
[[NSMutableDictionary alloc] initWithObjectsAndKeys:
#"I am doing XYZ", #"message",
#"123456abc",#"tags",
self.selectedPlace.id,#"place",
nil];
self.selectedplace.id does successfully contain the id of the Place, when i print it with debug/NSLog in console, it is holding the value accurately. but when i try to publish this after picking a place, I get "error: domain = com.facebook.sdk, code = 5"
Here is how self.selectedPlace is defined & synthesized:
#property (strong, nonatomic) NSObject<FBGraphPlace> *selectedPlace;
...
#synthesize selectedPlace = _selectedPlace;
...
[placePicker presentModallyFromViewController:self
animated:YES
handler:^(FBViewController *sender, BOOL donePressed) {
if (donePressed) {
self.selectedPlace = placePicker.selection;
}
}];
So, to sum my question: How can I successfully get this Place id that is stored in self.selectedPlace.id into the postParams dictionary, so that it can be successfully interpreted & published to the user's feed?
Also, I should warn everyone upfront... I am self taught and still learning, and although I can look at the code, understand what it does, and write it... I'm afraid I'm not great with the terminology & discussing/understanding some of the language... lol so it would help me a great deal if you keep that in mind in any answers or comments :) Thanks, and I'm looking forward to breaking out of my stackoverflow newb shell and becoming more apart of the community here.
Figured it out... rather than setting the post params collectively with initWithObjectsAndKeys, like this:
self.postParams =
[[NSMutableDictionary alloc] initWithObjectsAndKeys:
#"I am doing XYZ", #"message",
#"123456abc",#"tags",
self.selectedPlace.id,#"place",
nil];
Just create separate dictionaries for each param you are passing and set each one to the final postParams with setValue: forKey:
[fbPostParams setValue:self.selectedPlace.id forKey:#"place"];

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...!

facebook post action url error

Im working on posting to facebook on an ios app. I had it working fine but somehow it has stopped working. I have the users auth at this point and all thats fine it just keeps giving me this error when i try to post to facebook "the post's action links must be valid urls"
below is my code for the post
currentAPICall = kDialogFeedUser;
SBJSON *jsonWriter = [[SBJSON new] autorelease];
// The action links to be shown with the post in the feed
NSArray* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
#"someName",#"name",#"www.validurl.com",#"link", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
// Dialog parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
shareInfo.facebookShareText, #"name",//name is heading with link to above
#"text text text", #"caption",// caption makes text grayed out
#"more wonderful text", #"description",// block text for the share
shareInfo.shareUrlShort, #"link",//actual link
shareInfo.facebookShareImage, #"picture",//url of picture to be displayed
actionLinksStr, #"actions",
nil];
//the post's action links must be valid urls
//make post to wall feed
[_facebook dialog:#"feed"
andParams:params
andDelegate:self];
the post works if i remove the actionLinksStr from the params as the error says that the link within it is not valid. This has been working for months but just stopped when i tried it today and i cant seem to get it back working again. Has anyone any idea why this error would suddenly start happening with no change to the actual sharing code? the url im passing into the action link is definately valid. any help would be much appreciated thanks
edit: just gonna flag this as a bug on facebooks dev site. see if i can get any feedback from there. still a mystery to me
Make sure you are using a valid URL. In your code example above, change www.validurl.com to a complete URL: http://www.validurl.com