Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Facebook 3.1.1 SDK breaks A LOT
Started by haakon Dec 29 2012 08:39 PM

- - - - -
133 replies to this topic
[TOPIC CONTROLS]
Page 1 of 6 1 2 3 »
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

haakon

[GLOBAL: userInfoPane.html]
haakon
  • Contributor

  • 188 posts
  • Enterprise

Going through our final tests, we discovered that a) you have updated to Facebook SDK 3.1.1 and b) it breaks a lot of stuff.

First of all, the Cancel button in the Dialog is supposed to return the same as the Close button in the Dialog. Now it returns success and true and whatnot:

-- To print the facebook response
for k, v in pairs(event) do
    print(k)
    print(envy)
end

HITTING THE CANCEL BUTTON:

2012-12-30 13:04:21.680 mindfeud[20930:c07] string ::    type
2012-12-30 13:04:21.680 mindfeud[20930:c07] string ::    dialog

2012-12-30 13:04:21.681 mindfeud[20930:c07] string ::    name
2012-12-30 13:04:21.681 mindfeud[20930:c07] string ::    fbconnect

2012-12-30 13:04:21.682 mindfeud[20930:c07] string ::    didComplete
2012-12-30 13:04:21.682 mindfeud[20930:c07] boolean ::    true

2012-12-30 13:04:21.683 mindfeud[20930:c07] string ::    isError
2012-12-30 13:04:21.683 mindfeud[20930:c07] boolean ::    

2012-12-30 13:04:21.683 mindfeud[20930:c07] string ::    response
2012-12-30 13:04:21.684 mindfeud[20930:c07] string ::    fbconnect://success

-----

HITTING THE CLOSE CROSS BUTTON:

2012-12-30 13:05:24.231 mindfeud[20930:c07] string ::    type
2012-12-30 13:05:24.231 mindfeud[20930:c07] string ::    dialog

2012-12-30 13:05:24.232 mindfeud[20930:c07] string ::    name
2012-12-30 13:05:24.232 mindfeud[20930:c07] string ::    fbconnect

2012-12-30 13:05:24.232 mindfeud[20930:c07] string ::    didComplete
2012-12-30 13:05:24.233 mindfeud[20930:c07] boolean ::    

2012-12-30 13:05:24.233 mindfeud[20930:c07] string ::    isError
2012-12-30 13:05:24.233 mindfeud[20930:c07] boolean ::    

2012-12-30 13:05:24.234 mindfeud[20930:c07] string ::    response
2012-12-30 13:05:24.234 mindfeud[20930:c07] string ::

-------
Next out, the facebook session does not seem to survive for more than a few seconds. Maybe it is not being stored at all. After you updated to 3.1.1, authorization must be done every time we open a Dialog, and it must be done 2 times - first time it fails, second time it works. Then, as soon as the dialog is closed in one or another way, and we want to re-open the dialog, then the pattern repeats itself. We're asking publish_actions for everything in the app from login to getting friends lists to apprequests and wall posts, so it's not related to the permissions. Either way, this _worked_ before you updated the SDK.

uid: 21746 topic_id: 34416 reply_id: 334416


[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,779 posts
  • Enterprise

Can you make a small test case that demonstrates this and file a bug report?

Thanks
Rob
uid: 199310 topic_id: 34416 reply_id: 136792


[TOPIC: post.html]
#3

haakon

[GLOBAL: userInfoPane.html]
haakon
  • Contributor

  • 188 posts
  • Enterprise

Rob,

sorry, I don't spend time on writing test cases for you guys. I'd expect you to have a proper set of integration tests to catch bugs like this one before you build your product.

However, I took a minute to create a video showing the Close/Cancel bug, using your very own Facebook test project:

http://coronalabs.s3.amazonaws.com/corona_bug.mov

I also confirmed this bug to go back to before 3.3.1 by testing the 990 build, so slap on my own face for blaming the 3.1.1 update. This bug has been here for a long time, and I see in some old code of ours that we've worked around it by checking the facebook response for post_id/request_id etc.

I'm still not sure about the session related bug, I'll do some more testing and put up a video using your test app if I can find the exact way to reproduce it.
uid: 21746 topic_id: 34416 reply_id: 136811


[TOPIC: post.html]
#4

haakon

[GLOBAL: userInfoPane.html]
haakon
  • Contributor

  • 188 posts
  • Enterprise

This is weird. The "session bug" I suggested above is not happening. The problem is with permissions. I have found the steps to reproduce the actual bug with your own sample project.

I made another video showing the 3 changes I made to your main.lua file, and the funky stuff happening when running it.

In short, using the publish_actions permission is what breaks your implementation (you are using the "deprecated" publish_stream permission). publish_actions works in daily build 990 and older, but not in builds after you updated to 3.1.1.

Facebook is very clear about the recommended permission to ask by an app:

Permissions to write actions to a person's timeline must be requested separately from read permissions. We currently support three publishing permissions: publish_actions, publish_stream, and publish_checkins. Moving forward, we recommend that apps only ask for publish_actions, as this permission encompasses the other two and we want to simplify the model.

If you look at my video, you'll see an error message in the status text field:

The operation couldn’t be completed. (com.facebook.sdk error 5.)

Video: http://coronalabs.s3.amazonaws.com/corona_bug_2.mov
main.lua: http://coronalabs.s3.amazonaws.com/main.lua

uid: 21746 topic_id: 34416 reply_id: 136828


[TOPIC: post.html]
#5

haakon

[GLOBAL: userInfoPane.html]
haakon
  • Contributor

  • 188 posts
  • Enterprise

Any progress here? It's not much job for you to verify the bug, I've documented it well, and you only need to run your own Facebook project.

This is a complete showstopper for using builds newer than 990.
uid: 21746 topic_id: 34416 reply_id: 137194


[TOPIC: post.html]
#6

haakon

[GLOBAL: userInfoPane.html]
haakon
  • Contributor

  • 188 posts
  • Enterprise

Could it be a change in the Facebook 3.1.1 SDK?

https://github.com/mgcrea/cordova-facebook-connect/issues/22

Apparently since the latest facebook update you cannot request publishing permissions when initially logging in the user. Leave out the 'publish_actions' permission and you should be fine.

I'll try that and post my findings.
uid: 21746 topic_id: 34416 reply_id: 137196


[TOPIC: post.html]
#7

borderleap

[GLOBAL: userInfoPane.html]
borderleap
  • Contributor

  • 394 posts
  • Corona SDK

"The operation couldn’t be completed. (com.facebook.sdk error 5.)"

I'm getting this error also when trying to upload an image. This was working in the latest public release, but I'm using v996 now and it's not working.

The function I'm calling goes like this - I've replaced some of the vars with placeholder labels for reference...

function scene:uploadPictureToFacebook()
	
	-- listener
	local function fbListener( event )
	    if event.isError then
	        native.showAlert( "ERROR", event.response, { "OK" } )
	    else
	        if event.type == "session" and event.phase == "login" then
	            
	            local attachment = {
			        message = "[ Message goes here ]",
			        source = { baseDir=system.DocumentsDirectory, filename=MY_PATH_TO_SCREENSHOT, type="image" }
			    }
			    facebook.request( "me/photos", "POST", attachment )
	            
	        elseif event.type == "request" then
	            native.showAlert( "Screenshot Uploaded!", "The image has been uploaded to your Facebook timeline.", { "Ok, thanks!" } )
	        end
	    end
	end
	
	-- authenticate with FB...
        facebook.login( "MY_APP_ID", fbListener, { "publish_stream" } )
end

Has there been any update on this? Thanks.
uid: 131038 topic_id: 34416 reply_id: 137206


[TOPIC: post.html]
#8

borderleap

[GLOBAL: userInfoPane.html]
borderleap
  • Contributor

  • 394 posts
  • Corona SDK

"Apparently since the latest facebook update you cannot request publishing permissions when initially logging in the user. Leave out the 'publish_actions' permission and you should be fine."

Any testing done on this?
uid: 131038 topic_id: 34416 reply_id: 137208


[TOPIC: post.html]
#9

borderleap

[GLOBAL: userInfoPane.html]
borderleap
  • Contributor

  • 394 posts
  • Corona SDK

fyi - I'm testing this now using "publish_actions" rather than "publish_stream"...

https://developers.facebook.com/docs/concepts/login/permissions-login-dialog/

"Permissions to write actions to a person's timeline must be requested separately from read permissions. We currently support three publishing permissions: publish_actions, publish_stream, and publish_checkins. Moving forward, we recommend that apps only ask for publish_actions, as this permission encompasses the other two and we want to simplify the model. To ease the transition to this single permission, when asking for any one of these, the language presented to the person using the app is identical: "Social Hiking would like to post to your friends on your behalf."
uid: 131038 topic_id: 34416 reply_id: 137209


[TOPIC: post.html]
#10

borderleap

[GLOBAL: userInfoPane.html]
borderleap
  • Contributor

  • 394 posts
  • Corona SDK

After more testing, it just plain won't log me in at all - even with permissions changed to "publish_actions" as well as with permissions removed from the login() call.

Anyone experiencing this with the latest build?
uid: 131038 topic_id: 34416 reply_id: 137210


[TOPIC: post.html]
#11

borderleap

[GLOBAL: userInfoPane.html]
borderleap
  • Contributor

  • 394 posts
  • Corona SDK

Bug submitted.
uid: 131038 topic_id: 34416 reply_id: 137211


[TOPIC: post.html]
#12

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

I also had the same problem with the latest build, couldn't login or upload a picture anymore. But it actually worked on the iOS simulator, but not on the device. Then I removed the permissions and re-installed the Facebook App on my device and it worked again. But thats's only tested on my device.
uid: 98060 topic_id: 34416 reply_id: 137213


[TOPIC: post.html]
#13

haakon

[GLOBAL: userInfoPane.html]
haakon
  • Contributor

  • 188 posts
  • Enterprise

Hi, we have tested for several days now with a stable Facebook implementation. The key to solve the bug was to remove permissions from facebook requests that are GET. For example:

facebook.request("me")
facebook.request("me", "GET", {fields="id,username,name"})

and

facebook.request("me/friends")
facebook.request("me/friends", "GET", {fields = "id, name, installed"})

I can see why Facebook has done this change. We always asked publish_actions on all facebook logins to be able to post achievements to the user's wall from our servers. Now we're not getting that permission before the user has chosen to post something from the app.

I still think there's a Corona bug here, though. The Facebook SDK must have thrown an error when we tried to request publishing permissions when the user did a GET operation, but the error did not become visible to us before the user did the next operation.
uid: 21746 topic_id: 34416 reply_id: 138323


[TOPIC: post.html]
#14

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Corona SDK

"The operation couldn’t be completed. (com.facebook.sdk error 5.)"

I'm also getting this error (using daily build 1006). The code used to work. I believe the updated Facebook SDK integration caused this error to appear. In my case, the facebook.login( myAppID, myFBListener, {"publish_action"} ) seems to work just fine.

It breaks when I do the facebook.request( "me/friends" ) to pull down FB friends list. Immediately after facebook.request( "me/friends" ) is called, the console log shows:
didComplete: false
Error: HTTP status code: 400
event.name = 	fbconnect
event.type = 	request
isError = true
didComplete = false
RESPONSE: The operation couldn’t be completed. (com.facebook.sdk error 5.)

-- then it continues on with the following
event.name = 	fbconnect
event.type = 	session
isError = false
didComplete = nil
FBConditionalLog: handleOpenURL should not be called once a session has closed

Is there a workaround for this?

@haakon, I'm not sure how I may apply your finding to my case.

@borderleap, have you heard from CoronaLabs regarding the bug you reported? Should I create and submit some test case too?

There's nothing very complex about my setting. It simply breaks when I try to pull down user's friends' name and FB ID. The code used to work just fine...

Naomi
uid: 67217 topic_id: 34416 reply_id: 139610


[TOPIC: post.html]
#15

haakon

[GLOBAL: userInfoPane.html]
haakon
  • Contributor

  • 188 posts
  • Enterprise

Naomi, you need to concider what you are doing after the login phase. If you are doing a GET operation after the login phase, like get "/me" or get "/me/friends", then your login phase must be done without requesting any publishing permissions (publish_stream, publish_actions etc).

When "/me" or "/me/frieds":
NO: facebook.login( myAppID, myFBListener, {"publish_action"} )
YES: facebook.login( myAppID, myFBListener)

Hope that makes sense. If you find something not working after logging in with publishing permissions, just remove the permissions from the login call.
uid: 21746 topic_id: 34416 reply_id: 139623


[TOPIC: post.html]
#16

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Corona SDK

Ah, of course. @haakon, thank you so much for clarifying it. After reading your reply post #15, I re-read your post #13 above, and it clicked. (I can't believe I didn't get it the first time around, especially since you did include facebook.request("me/friends") in the GET list. Yikes, I was blind.)

Thanks again!!

Naomi
uid: 67217 topic_id: 34416 reply_id: 139653


[TOPIC: post.html]
#17

antonyburrows

[GLOBAL: userInfoPane.html]
antonyburrows
  • Enthusiast

  • 31 posts
  • Corona SDK

Hi All,

Thanks for this thread, it's stopped me going mad debugging this issue. I have one stupid question if I may? How do I now get the publish permission when I need it? Do I just re-login or is there a better way?

Eg
1: Login (without publish)
2: Get friends etc
3: ????? (something to get the appropriate permission)
4: Post to users wall

I am trying to call the login function again (with the added permissions) - but all it does is open FB for a few seconds, returns to my app and fails. It doesn't prompt the user to grant the additional permissions.

Thanks

Antony

uid: 169392 topic_id: 34416 reply_id: 139670


[TOPIC: post.html]
#18

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Corona SDK

Hey, Antony, I updated my FB implementation as per haakon's note, and it works fine for me:

1) When I just log my user in to FB, I do this, and this seems to work fine. Even though I'm pulling down the user's FB data in the process, it didn't cause any error. I wonder why. Maybe I should test this again just in case:
facebook.login( myAppID, myFBListener, { "email" } )

Edit: I did a fresh install (after wiping my device), and it turns out that simply logging into FB with permission works fine. However, if I proceed to step 2 below (pulling down the FB friends list), it fails. If I login with permission first, and then call facebook.logout() before proceeding to step 2, it works fine. So, it seems like the options I have is to either log user out immediately after I log them in with permission, or not require permission at all when user connects with FB during the registration process...

2) When I need to pull down FB friends list, I do this, and it works like a charm:
facebook.login( myAppID, myFBListener)

3) When I need to POST a message on FB wall, I do this, and it works like a charm:
facebook.login( myAppID, myFBListener, {"publish_action"})

4) By the way, I was also able to POST a message even when I removed the permission (but I decided to keep the permission for my app):
facebook.login( myAppID, myFBListener)

Naomi
uid: 67217 topic_id: 34416 reply_id: 139683


[TOPIC: post.html]
#19

antonyburrows

[GLOBAL: userInfoPane.html]
antonyburrows
  • Enthusiast

  • 31 posts
  • Corona SDK

Hi Naomi,

This page was quite helpful
https://developers.facebook.com/docs/howtos/login/handling-revoked-permissions/
They basically say, only ask for permissions as as you need them - and hint you need to go through the relogin process.

So in my testing I did this (although I am using Bob Dickinson's FB helper - so my calls are slightly different)

1: facebook.login( myAppID, myFBListener, { "email" } )
2: Get friends - Works fine
3: facebook.login( myAppID, myFBListener, { "publish_action" } )
4: post to users wall

Step 3 failed for me, as it never actually prompted the user to authorise the new permission (yes I had cleared the authorisation in FB) and so step 4 failed with an error.

Maybe you do need to logout and in again as you have suggested - but to be honest I really wanted to get the next update to my app out so I reverted back to build 990, submitted the app version and decided to re-look at this issue when I need to do the next update!

Antony
uid: 169392 topic_id: 34416 reply_id: 139823


[TOPIC: post.html]
#20

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Corona SDK

Hey, Antony, after I wiped my device and clean slated FB test user account, I'm getting the similar result as yours.

It was working fine (as I described in post #18) yesterday. But today, after I clean slated my test device and FB test user account, posting to user's friend's wall completely fails with Error: HTTP status code: 403

1: facebook.login( myAppID, myFBListener, { "email" } ) - works fine
2: facebook.request( "me/friends" ) - works fine (and fetches friends list)
3: facebook.login( myAppID, myPostListener, { "publish_actions" } ) - logs in fine
4: facebook.request( feedMyFriend, "POST", attachment ) - fails with HTTP error

The code for step 4 used to work (it worked yesterday), but now it doesn't. Ugh.

Naomi

Edit 1: I went back and looked up FB Graph API:
https://developers.facebook.com/docs/reference/api/publishing/
Regarding the /PROFILE_ID/feed method (for publishing a new post on the given profile's feed/wall), it says Note that this feature will be removed soon.

Yikes, maybe that's why it's not working anymore. Urrrrrgh. How frustrating.

Edit 2: Here's a relevant post by @george18 (thank you george18):
http://developer.coronalabs.com/forum/2012/11/22/has-facebook-posting-stopped-working-last-week#comment-132107

Sounds like I need to invoke feed dialog...
uid: 67217 topic_id: 34416 reply_id: 139872


[TOPIC: post.html]
#21

antonyburrows

[GLOBAL: userInfoPane.html]
antonyburrows
  • Enthusiast

  • 31 posts
  • Corona SDK

I wonder if that only applies to the new SDK? It's currently working fine in my live app which uses the old one.

Either way I guess it's time to make the change and get ready to submit to apple for when the feature does go away. It's frustrating as I have only just submitted the latest version to Apple!
uid: 169392 topic_id: 34416 reply_id: 139973


[TOPIC: post.html]
#22

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Corona SDK

So I updated my script from facebook.request to facebook.showDialog( "feed", attachment ), and it did the job very well. Ahhhh, what a pleasure it is to work with Facebook.

Naomi

P.S. And here's a great tip from AlanPlantPot about what showDialog returns:

http://developer.coronalabs.com/forum/2012/12/06/how-can-i-post-text-facebook-feed-dialog#comment-134151
uid: 67217 topic_id: 34416 reply_id: 139974


[TOPIC: post.html]
#23

haakon

[GLOBAL: userInfoPane.html]
haakon
  • Contributor

  • 188 posts
  • Enterprise

Naomi,

I'm glad you discovered that yourself. It was on my GTD today to make a comment about that possibility. The dialog working is not weird at all. It needs no permissions, since what is posted is user controlled - not server or app controlled.
uid: 21746 topic_id: 34416 reply_id: 139975


[TOPIC: post.html]
#24

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Corona SDK

Thanks, Haakon. I really wanted the facebook.request to work, especially since we can pre-determine what gets posted.

With facebook.showDialog, I would be happier if we could pre-fill the text message that the user could send. I wouldn't mind the user editing it. It's just that pre-filling would make it so much better for the app, and makes it so much easier for the user too. But from Facebook API page, it doesn't look like there's any way they would allow pre-filling the message:

https://developers.facebook.com/docs/reference/dialogs/feed/

If I'm mistaken, please let me know.

Naomi
uid: 67217 topic_id: 34416 reply_id: 139980


[TOPIC: post.html]
#25

antonyburrows

[GLOBAL: userInfoPane.html]
antonyburrows
  • Enthusiast

  • 31 posts
  • Corona SDK

Naomi, I have not been able to find a way... and all I have read says you can't do that anymore. Instead I am using the name, caption and description fields to get the message across.

One issue I am now having, is that my previous link would cause the device to launch the app store or app. Now that I am using the feed dialog, it causes facebook to load the app page. Any idea how I get around that, I don't want to give users an extra step?

This is my current URL, perhaps there is another one I should use?
"https://www.facebook.com/apps/application.php?id=267797749998454"

Antony
uid: 169392 topic_id: 34416 reply_id: 139997



[topic_controls]
Page 1 of 6 1 2 3 »
 
[/topic_controls]