Facebook Feed Dialog keeps asking for permission - iphone

I've been trying to post a link on user's wall, by using Facebook SDK for the iOS.
I'm trying the code below and it works perfectly when I don't have the Facebook App installed. But when I have it, it just ask me to authenticate and send me back to the App. It happens even just to say that I've already gave the necessary permission, but never shows the dialog to do the share.
The code is:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithFormat:#"%# %.0f%% OFF", self.offer.description,
[self.offer.price.discountPercent doubleValue] * 100], #"name",
self.offer.store, #"caption",
self.offer.imageKey, #"picture",
#"Test", #"description",
[NSString stringWithFormat:#"http://my_url.com/id%#", self.offer.offerId], #"link",
nil];
[facebook dialog:#"feed" andParams:params andDelegate:self];
Any idea? Thank you in advance ;)

I think this is becouse of you login/logout code. when you making an autorization request to FB, one of params you sending is how long access token must "live". Make shure it lives long anoth. Or, somewhere in the code you invalidating it. May be even losting pointer to access token or something. Make sure, that acces token you use to post is validate at the moment you posting. I suggest you to use official SDK for FB: it's really simple and without any problems. There is great tutorial how to use it: http://developers.facebook.com/docs/mobile/ios/build/

Related

How to limit facebook apprequests to certain users?

I have a iOS mobile application that needs to send out an app request to a user's friends. From here:https://developers.facebook.com/docs/howtos/send-requests-using-ios-sdk and here:https://developers.facebook.com/docs/reference/dialogs/requests/#mfs it appears I am able to suggest the users that this app requesst gets sent to. I am making the call like this:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Check out this awesome app", #"message",
#"1xxx4,10xxxx0,", #"suggestions",
nil];
[self.facebook dialog:#"apprequests"
andParams:params
andDelegate:nil];
However, once the multi-friend request dialog is presented, I am still able to type in a friends name, even if it was not part of the "suggestions". How do I make this restriction?
The end goal is to restrict that list to facebook friends who are not users of this app. The docs also mention a "filters" parameter, but i have not got that to work.
Ideas?

FaceBook app request is shown on website only, but not on FB app

I'm sending an app request from my iphone app, using this code:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Join my app", #"message", [NSString stringWithFormat:#"%#", [[filteredContacts objectAtIndex:path] valueForKey:#"id"]] ,#"to",
nil];
[facebook dialog:#"apprequests"
andParams:params
andDelegate:self];
while [[filteredContacts objectAtIndex:path] valueForKey:#"id"] returns a facebook ID value.
When a FB friend of mine gets the request he can see it in the notifications section on his facebook - but only on the website itself.
When trying to find it in the facebook iphone app - it's just not there. also, it's not found on the mobile site.
How can it be posible that I see the notification on the website only?
Well the answer was very simple -
I should have define the app as a mobile app when I created it as a FB app.

Facebook Connect Posting a Status Update

HI I have got Facebook Connect working with a functional login and logout button. So far thats it, when I press a button a I want to post something to the user. Is there something I have to authorize? What is the precise steps for this. Thank you.
If you want to publish content to User's Feed you not required to authorize user if you use Feed Dialog for any other ways you required to authorize user prior to content publishing.
For web applications/sites (which isn't the case) there is also way to leverage automatic publishing of content user liked using Like Button social plugin by providing correct OpenGraph meta tags.
You really need to read documentation for iOS SDK, especially Dialogs and Authentication and Getting Started Guide.
if you want to set his status thought your FB app without showing a dialog you could do it like this
NSString *message = #"some text";
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, message,nil];
[fb requestWithGraphPath:#"me/feed" andParams:params andHttpMethod:#"POST" andDelegate:self]; //fb here is the FaceBook instance.
and for sure you will do that after the user login and authorized the permissions .
To Authorize the permissions
if (![fb isSessionValid]) {
NSArray *permissions = [[NSArray alloc] initWithObjects:#"user_likes", #"read_stream", nil];
[fb authorize:permissions];
[permissions release];
}

Posting to message Facebook from iPhone/iPad

I have a 2-part question about posting messages to Facebook.
1 - I want to pre-populate the message that the user is going to post i.e. where it says 'Say something about this...'. Is this possible? If so, how? At the moment I have the following setup to produce the post shown below:
NSMutableDictionary *params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Steak Expert", #"name",
#"The must-have iPhone/iPad app for carnivores!", #"caption",
#"Steak Expert helps you to cook every steak to perfection! With this app in your hand you'll never need to worry about over-cooking or under-cooking a steak again. Perfection every time! ", #"description",
#"https://m.facebook.com/apps/MY_APP_ID/", #"link",
#"http://fbrell.com/f8.jpg", #"picture",
#"Cooking a steak using Steak Expert!", #"message", // I thought this would be the required field to populate the text
nil];
[facebook dialog:#"feed" andParams:params andDelegate:nil];
2 - The other part of my question is based around the view shown above. Is it possible to automatically post to the wall without the need for this view to appear? Seeing as the user must authorise the app to even connect with Facebook (plus any other specified actions) I can't see it being an issue. If so please could someone advise on how to achieve this?
It is the message field that you are talking about.
message - This field will be ignored on July 12, 2011 The message to prefill the text field that the user will type in. To be compliant with Facebook Platform Policies, your application may only set this field if the user manually generated the content earlier in the workflow. Most applications should not set this.
http://developers.facebook.com/docs/reference/dialogs/feed/
Hope this helps
As #Illep stated, the message field no longer works for the dialog postings.
To answer your second question, you can use the graph API to straight post to a user's wall without showing the dialog box. Take a look at the documentation here. You would use the following code to write the message:
// Set parameters
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:FACEBOOK_ACCESS_TOKEN forKey:#"access_token"];
[params setObject:#"Some preset message" forKey:#"message"];
// Make the request to the graph API
[_facebook requestWithGraphPath:#"me/feed" andParams:params andHttpMethod:#"POST" andDelegate:self];

Objective-C/iPhone - oAuthException when using "me/checkins" as part of the Facebook Graph API

I am receiving the following graph response when checking users into Facebook using the Facebook Graph API. I am using the facebook-ios-sdk within my iPhone application to do this.
{"error":{"type":"OAuthException","message":"An unexpected error has occurred. Please retry your request later."}}
I have not made any changes to my code today and I know for a fact (database logs, etc) that their have been successful checkins yesterday.
I'm asking the SO community whether or not they have received similar errors and how they attempted to resolve them?
I have already tried the following:
Revoked access to my application via Facebook.
Reset my offline_access token by forcing Facebook to generate a new one.
Keep in mind my application successfully shares via peoples Facebook walls as well and this is working as expected without any problems.
I request the following permissions from my users:
#"offline_access", #"publish_stream", #"publish_checkins", #"email"
EDIT:
Okay, so this is quite strange and I'm thinking that it's an error on Facebook's end.
I use the following code to tag friends in the checkin:
if ([self.selectedFriends count] > 0) {
[variables setObject:[self.selectedFriends componentsJoinedByString:#","] forKey:#"tags"];
}
fb_graph_response = [fbGraph doGraphPost:#"me/checkins" withPostVars:variables clientId:accessToken];
self.selectedFriends is simply an NSMutableArray of Facebook profile ID's separated by commas, which is what the graph API says to use and remember this has been working fine for months.
http://developers.facebook.com/docs/reference/api/checkin/
If I remove the [variables setObject:[self.selectedFriends componentsJoinedByString:#","] forKey:#"tags"]; then the checkin works just fine for me.
It fails every time I tag one or more friends. Is anyone else receiving the same error when tagging friends in a checkin?
UPDATE 1:
Looks like other people are receiving the same problem relating to Groups:
http://forum.developers.facebook.net/viewtopic.php?pid=349396
I wonder if there's a bug at the moment relating to Checkins.
I've posted a bug:
http://bugs.developers.facebook.net/show_bug.cgi?id=18134
UPDATE 2:
Facebook were able to reproduce the bug and they're now looking into it.
i m using checkins in one of my applications , Regarding your issue ,
Yes , you are right , i had this OAUTH Exception only when sometimes you made checkins continuously with tagging friends,
Also allow permissions like #"user_checkins", #"friends_checkins", in your application
please check this link :
http://tylerwhitedesign.com/how-to-check-in-using-the-facebook-ios-sdk-and-graph-api
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[dictionary objectForKey:#"place"], #"place", //The PlaceID
coordinates, #"coordinates", // The latitude and longitude in string format (JSON)
message, #"message", // The status message
tags, #"tags", // The user's friends who are being checked in
nil];
[_facebook requestWithGraphPath:#"me/checkins" andParams:params andHttpMethod:#"POST" andDelegate: postCheckinRequestResult];
Hope this helps!