Facebook API and Open Graph v2 issues

So Facebook have recently updated their API to a newly versioned system. v1.0 and v2.0 or old calls can remain using the unversioned mode. 

Since the new api was released, im having trouble with the facebook.login command whereby when i make a second call to get extended permissions, i get 

May  4 14:07:46 Craigs-iPad MyGameName[3064] <Error>: +[FBSession isPublishPermission:]: unrecognized selector sent to class 0x38a2ac

May  4 14:07:46 Craigs-iPad UIKitApplication:net.mycompany.myproduct[0x18be][3064] <Notice>: Generic error: NSInvalidArgumentException: +[FBSession isPublishPermission:]: unrecognized selector sent to class 0x38a2ac

May  4 14:07:46 Craigs-iPad UIKitApplication:net.mycompany.myproduct[0x18be][3064] <Notice>: (

May  4 14:07:46 Craigs-iPad UIKitApplication:net.mycompany.myproduct[0x18be][3064] <Notice>: 0   CoreFoundation                      0x37fee8a7 __exceptionPreprocess + 186

May  4 14:07:46 Craigs-iPad UIKitApplication:net.mycompany.myproduct[0x18be][3064] <Notice>: 1   libobjc.A.dylib                     0x3331f259 objc_exception_throw + 32

May  4 14:07:46 Craigs-iPad UIKitApplication:net.mycompany.myproduct[0x18be][3064] <Notice>: 2   CoreFoundation                      0x37ff192f +[NSObject doesNotRecognizeSelector:] + 174

May  4 14:07:46 Craigs-iPad UIKitApplication:net.mycompany.myproduct[0x18be][3064] <Notice>: 3   CoreFoundation                      0x37ff0915 ___forwarding___ + 300

May  4 14:07:46 Craigs-iPad UIKitApplication:net.mycompany.myproduct[0x18be][3064] <Notice>: 4   CoreFoundation                      0x37f4b650 _CF_forwarding_prep_0 + 48

May  4 14:07:46 Craigs-iPad UIKitApplication:net.mycompany.myproduct[0x18be][3064] <Notice>: 5   MyGameName                    0x001d8409 _ZNK6Corona12IOSFBConnect5LoginEPKcPS2_i + 264

May  4 14:07:46 Craigs-iPad UIKitApplication:net.mycompany.myproduct[0x18be][3064] <Notice>: 6   MyGameName                    0x001da461 _ZN6Corona15FacebookLibrary5loginEP9lua_State + 204

<there are more entries which i can post if needed>

Now prior to the new fb sdk release this has been working fine for me. My app is still in development (was about to start final testing cycle), i have been using the FB -> DevPortal -> Roles -> Test Users. Now it seems that any new test users i create will generate this error when i try to login with them, regardless of what API version i specify that they are using (you can set API level when you turn on Authorize Test Users for This App? setting when creating the test user). Leaving that setting off completely also has the same effect. 

Older test users that i created prior to the fb upgrade and have logged in with before still work fine.

The error occurs when i request the “publish_actions” permission after i have logged in. 

It is my understanding that you generally need to request extended permissions after the login call by issuing a second login request for the extended permissions. So my code effectively does the following

– calls login initially with no params

facebook.login( fbAppID, facebookListener )

– once the listener returns that the login was successful i query the available permissions for the access token by doing the following

network.request( “https://graph.facebook.com/me/permissions?access_token=” … tostring(fbAccessToken), “GET”, verifyPermissionsListener, myParams ) 

I then check the returned permissions and if publish_actions isn’t available i then ask for it by doing

facebook.login( fbAppID, facebookListener, { “publish_actions” } )

This is the point where the above error occurs, as soon as i make that second login call. 

As mentioned, this was working fine for me previously, i have been doing alot of testing and deveopment work using the fb api over the last month without any problems, and have 7 older test users that all work fine using this method, its only since the new api was released that any new test users i create wont work.

All of the above was done with the latest public release, build 2189a. I have also downloaded the latest daily build 2295 and got the same result (i only gave it one try on this build with a test user set for v2 api). 

Please advise on

  1. am I going about requesting extended permissions in the correct way, 

  2. what is the cause of the error shown above

  3. is there more work to come in the daily builds to support the new fb v2.0 api as it would be preferable to switch over to that before releasing if it wont cause too many delays to my release. 

Cheers

Craig

Is there a reason you are using network.request instead of facebook.request to get the permissions?

As far as I know the only recent change was to move to SDK v3.14 from V3.13 and you need to make two login calls to request the second set of permissions. 

Can you try and build the facebook sample app?

Rob

Rob, 

I just noticed some changes in daily build 2014.2292 to the facebook plugin/support… 

Update the iOS facebook project to use the latest facebook sdk. Also removed greenthrottle from enterprise. We're keeping facebook here instead of moving it to the plugins repo because we still want to package it with enterprise. iOS: The facebook SDK changed the location of the resource bundle. Pointing it to the new correct location.

Could you kindly tell us if we need to make any changes in our app to cater for this update? Thanks

As far as I know this has no impact on Corona SDK users and we didn’t change the location to avoid impacting Enterprise subscribers as well.  We were hoping Facebook would have fixed their IDFA issues, but that seems to still be an issue.

Rob

Ok. Getting close to releasing an app which is working for me in testing but worried about post-release issues. I ignored the IDFA stuff till now. Let me go do some reading up to understand what the problem is. Thanks

I’ve been encountering a similar issue since FB made the change to Graph 2.0 - I would recommend you or one of your testers who can currently log in and get the required permissions remove the app from your FB account (on Facebook.com, go to privacy settings–>apps and remove your app from the list of approved apps). This effectively clears out the access token and forces the app to request the necessary permissions again, as if for the first time. I suspect it won’t work after taking these steps - when I did this myself (I’m requesting “read_stream” and “publish_actions” in my app, though not at the same time), the only way I could get things working correctly again is to go into the Facebook Graph Explorer and get an access token manually. I’d be curious to hear if this is your experience as well.

Under Graph 2.0, it sounds like FB is implementing a review process for any app that want to request more than the most basic permissions (that would include “publish_actions”) - I copied this from https://developers.facebook.com/docs/facebook-login/permissions/v2.0#permission-publish_actions :

If your app asks for more than than public_profile, email and user_friends it will require review by Facebook before your app can be used by people other than the app’s developers.

In the FB Developer portal, there is now a “Status & Review” tab where you can submit a review request to grant your app the ability to request more sensitive permissions. Personally this seems like overkill to me - we have to endure a 1-2 week review process in order to request our users to grant us permissions? It’s an awful lot of hoops to jump through. And despite the fact that they claim that this review only applies to “people other than the app’s developers,” in my experience I’m still being prevented from requesting these permissions on my own account.

On the whole, I’m pretty unimpressed with the rollout of Graph 2.0 - all these hoops to jump through notwithstanding, they got rid of useful features like public post searching, which I was planning on using in an upcoming app. Grrrr. Stupid Facebook.

Please keep posting any findings related to this issue here - I was getting very close to releasing a heavily Facebook-integrated app, and now I’m thinking I’ve been set back weeks if not months on account of these very sudden changes to the way the FB API works. Any useful information from the community would be much appreciated!

Thanks,

Jason

@Rob - I have tried this with the corona facebook sample app and have the same problems. 

May  5 17:58:11 Craigs-iPad Facebook[3235] <Error>: +[FBSession isPublishPermission:]: unrecognized selector sent to class 0x3852ac

Same things applied, a user i created a month or so ago when i last played with the facebook sample app still works fine, but any new user (regardless of how i set them up) will result in the above error when the second login is called. So using the sample app, when you first start it it will automatically bring up the facebook login prompt, you put in the login details of a new user, it asks to auth the app you say ok, and the app loads and says logged in. As soon as you try to do any of the functions (like Post Msg), the code for that attempts a second login to get “publish_actions” permissions and you get the above error in the log and the function doesnt work. 

Tests were done with latest public release.

@Craig:

Can you try removing your app from your Facebook account in privacy settings, then re-logging in from your app? I’d be curious to see if you encounter the same issue I was: that even previously successfully logged-in accounts do not get tokens for anything beyond the most basic permissions when logging in for the first time? I suspect that this is a bug on Facebook’s end related to the new review process for extended permissions requests - they say that development teams should be able to access extended permissions without going through review, but that doesn’t seem to be the case. You can always add back the permissions manually by getting a custom token assigned to your account using the Facebook Graph Explorer (https://developers.facebook.com/tools/explorer/)

Thanks,

Jason

@Jason

You are correct, taking an older account that was working fine and removing the app from the privacy settings and then trying to use it now results in the problem of not being able to get any extended permissions. So the initial request on existing accounts seems to be returning the extended permissions by default, but a new account (or one that has had the app removed) will only allow basic permissions and will cause the error in my previous post when requesting extended permissions. 

Cheers

Hi All,

Same problem here.

I’ve got an app that’s pretty close to release, and now it seems there is no way to get extended permissions.

That’s a pretty big show stopper for me.

I suspect that going through the approval/review process with Facebook (which they advise will take 7-14 business days) will be how we get around this. But I’m still pretty miffed that we have to go through that headache in the first place - the user already has the ability to deny access, so why the arbitrary approval process? But regardless, it’s a bug that members of the development team can’t access these permissions with an app under development - it’s contrary to what Facebook’s own documentation would seem to suggest.

I’ll try to file a bug report with FB and will post any updates here - but if anybody at Corona Labs has a relationship with Facebook engineering and can sweet-talk them into fast-tracking a solution to this, I’m sure we’d all appreciate it. :slight_smile:

Thanks,

Jason

Facebook bug filed: https://developers.facebook.com/bugs/649529008416388/

Please check in and +1 it if you can…the more attention we can get from Facebook, the better!

Thanks,

Jason

I’m working on an app that incorporates social aspects for the first time, and Facebook’s stranglehold on the social media market is really bumming me out. Mostly because their, as Jason said, arbitrary approvals and the backflips developers need to perform in order to allow Facebook to work with their apps seems counter-intuitive. At this point, I’d rather leave Facebook out, and just use Twitter, G+, Tumblr, Mi5, Orkut etc without worrying about it.

I will be moving through the process of Facebook app approval just for documentation purposes, and I’ll report back with my findings. Jason, I went to your bug page, but I didn’t see a place to +1 it. Do I need to be a super-special Facebook developer in order to weigh in on it?

@Panc,

Thanks for checking it out. This is my first time reporting bugs to Facebook, so I’m honestly not sure what is available to 3rd parties in terms of +1ing - when I look at the report there’s a place for commenting, and since the bug report is public, I assumed everybody would be able to comment. But perhaps that’s not the case.

Sorry for the miscommunication, and thanks for pitching in!

Hi everyone, same issue for me… I don’t seem to be able to request Facebook extended permissions anymore (was working fine a couple of weeks ago).  I also assumed this was because my Facebook app now needs to go through a review process.  However, I removed all extended permissions that required a review process by Facebook.  I’m now only requesting the email extended permission, but event.response.email is nil in my Facebook listener.

@Rob, you mentioned that we now need to make a second login call as of V3.14 iOS Facebook SDK.  Is there a link to this in the Corona docs anywhere?  I can’t find any mention of this in the facebook.login() documentation:

http://docs.coronalabs.com/api/library/facebook/login.html

nor the Implementing Facebook documentation:

http://docs.coronalabs.com/guide/social/implementFacebook/index.html

If anyone can point me in the right direction, I’d be very grateful.  Here’s my code, for clarity:

[lua]  

        local function facebookListener( event )

            if not event.isError then 

                if event.type == “session” then

                    print(“event is session”)

                    if event.phase == “login” then

                        print(“logging in”)

                        sessionToken = event.token

                        sessionExpiry = event.expiration

                        print(event.token)

                        if sessionToken then

                            facebook.request( “me” )

                        end

                    end

                elseif event.type == “request” then

                    if not event.isError then

                        local fbResponse = json.decode(event.response)

                        print(“event is request”)

                        print("event.response = " … event.response)

                        print("event.response.email = " … fbResponse.email)

                    else 

                        local alert = native.showAlert( “Oh No”, “Facebook Connect Error!” , {“ok”} )

                    end

                end

            else 

            end

        end

        facebook.login( fbAppId,facebookListener,{ “email” })

[/lua]

@edmoyse,

I don’t personally use the “email” permission, so it could be I’m missing something, but taking a look at your code it looks like you are not decoding the JSON string that Facebook returns into a Lua table, which could be why event.response.email is nil. Try changing your code block that handles “request” event types (lines 15 through 23 in the example you pasted above) to the code below and let us know if it works. Don’t forget to include the JSON library by adding local json = require(“json”) somewhere in your code, or else the below won’t work:

elseif event.type == "request" then if not event.isError then local FBresponse = json.decode(event.response) print("event is request") print("USER EMAIL IS " .. FBresponse.email) else local alert = native.showAlert( "Oh No", "Facebook Connect Error!" , {"ok"} ) end end

Thanks for posting the bug. I found that there is a Reply box underneath your report so I placed a +1 blurb in there. All other devs can do the same I suppose although I have no idea whether FB will care or not. Again, thanks for taking the time. 

@schroederapps, sorry - carelessness on my part when copying code across… I do decode the response (EDITED my comment above), but I’m still encountering the same issue (I’m also printing event.response to the terminal - and no email address is returned).

EDIT: Also, when the Facebook app opens, there is no permissions pop-up for the email address (Facebook only requests basic user info and friends list permissions)

Hey guys,

So Facebook has responded to my bug report with a request for more information. I provided as much detail as I could, but since Corona places a bit of a buffer between my code and the actual Facebook SDK, it was hard for me to tell if the info I provided was what they were looking for.

While we’ve got their attention, PLEASE everybody go to https://developers.facebook.com/bugs/649529008416388/ and add comments with as much detail as you can on your individual experiences with this bug. And Rob (or somebody at Corona Labs), do you think there’s a chance one of you could get involved to provide a more technical summary of what might be going on between Corona & the Facebook SDK? I think if we make enough noise and give them as much information as we can, there’s a chance we’ll get some resolution here.

Thanks!

I can’t promise anything, but I’ve alerted Engineering to this thread.

Rob