Facebook API - problems

Started playing with the Facebook API calls tonight and have been pulling out my hair. But I suspect the following.

I am trying to invoke:

1
                                facebook.request( "me/feed", "POST", postMsg )

I've done that - flooding it, I mean - last I checked (it may have changed since) they temporarily stop it from making new posts to your wall.

OOI, have you been using the example FB code from the .591 Corona SDK Sample Code folder?

Peach, I don't think I'm using example FB code from .591 - where do I find that?

I'll try and search/look, but what is it about the example FB code that you're thinking about?

Note: I was going to check this video link out from June 2011:
http://mobile.tutsplus.com/tutorials/corona/corona-sdk-working-with-the-facebook-graph-api/

>>example FB code from the .591 Corona SDK Sample Code folder?

OK looking in my Sample Code directory now... thanks!

Hey Jerome,

That's right - CoronaSDK > SampleCode > Networking > Facebook

Peach :)

Peach, that app worked just fine, thanks!

Somehow my test FB page is blocking or not allowing posts from my FB App. I don't know if FB blocked me because I accidentally flooded it with facebook.request( "POST" ) calls or what...but somehow it's not allowing posts. My personal FB page allows it just fine. I made another Test user FB page and that works great.

OK, moving on. Awesome.

Although I do have a question, sample code that allows the user to post internal photos from user library on the device - as opposed to from a URL - would be preferred I would think. If games want to dynamically post information from their game, they don't want to have to upload graphics to a website just to refer to the URL.

There's probably an easy workaround to this I haven't thought about it too much, just shootin' from the hip here. But it seems to be the more "practical" application of sharing info on FB.

Well I restored my code back to the Sample Code from the SDK for Facebook; changed the appId to my string and then the code worked fine... so from within my game I was posting to facebook with only one strange behavior, it was posting twice instead of once. And now the app won't post anymore - so again I don't know if FB is suspending me for some reason or not.

Facebook code has been troublesome from the word go - but probably API user error on my part. I guess. Back to the debugging board.

SOLUTION: What I have deduced is that the sample code in main.lua does not clear out fbCommand state flag with nil once you're in the event.type "session". The problem here is that you can repeatedly attempt to facebook.request() due to the listener triggering periodically. I recommend people try this if they start having mirror posts:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    if ( "session" == event.type ) then
        -- event.phase is one of: "login", "loginFailed", "loginCancelled", "logout"
                statusMessage.textObject.text = event.phase             -- tjn Added
 
                -- This code posts a photo image to your Facebook Wall
                --
                if fbCommand == POST_PHOTO then
                        fbCommand = nil
                        fbCommandResponse = POST_PHOTO
                        local attachment = {
                                name = "Developing a Facebook Connect app using the Corona SDK!",
                                link = "http://www.acme.com",
                                caption = "Link caption",
                                description = "This is a gorilla.",
                                picture = "http://www.acme.com/gorilla.jpg",
                                actions = json.encode( { { name = "Learn More", link = "http://www.acme.com" } } )
                        }
                
                        facebook.request( "me/feed", "POST", attachment )               -- posting the photo
                end
views:1670 update:2011/10/4 17:12:07
corona forums © 2003-2011