Facebook Error 5 Issue

Using latest daily build 2014.2231

So since Corona fixed the posting local image to Facebook I thought I was all set to release my app.  Unfortunately not it seems as there is a horrible bug that happens all the time whilst posting a message, image link or local image.  I know that everything is set up good because it will eventually post.  This is for iOS.  Here is the flow whilst trying to post an image link as per the example:

FaceBook Flow:

App Deleted from iPhone

FaceBook App newly Installed and logged in and made sure that my game is not setup in settings>apps via browser.  i.e. a new install as a new user of my app would see.

Logged in  to facebook via Settings

Reinstall App

Image Link Test

Press Login to Facebook > Logged in is true

Press Upload to Facebook> 

Error: HTTP status code 400 on console

Error:  The operation couldn’t be completed. (com.facebook.sdk error 5.) on iPhone

Press upload to Facebook again>

My game would like to access your basic profile info and list of friends

Press OK

Error:  The operation couldn’t be completed. (com.facebook.sdk error 5.) on iPhone

Press upload to Facebook again>

My game would like to post publicly on your behalf

Press OK

Success!  Your image link has been posted to Facebook

Posting is then successful from here on in.

I can’t release my app having new users see this mess once they try to post their first image.

[lua]

local function fblistener(event)

if event.isError then

        alert = native.showAlert( “ERROR”, event.response, { “OK” } )

else

        if (event.type == “session”) and (event.phase == “login”) then

                local attachment = {

                        name = “Developing a Facebook Connect app using the Corona SDK!”,

                        link = “http://www.coronalabs.com/links/forum”,

                        caption = “Link caption”,

                        description = “Corona SDK for developing iOS and Android apps with the same code base.”,

                        picture = “http://www.coronalabs.com/links/demo/Corona90x90.png”,

                        actions = json.encode( { { name = “Learn More”, link = “http://coronalabs.com” } } )

                    }

        

                    facebook.request( “me/feed”, “POST”, attachment )

        elseif event.type == “request” then

                if ( not event.isError ) then

                        alert = native.showAlert(“Success”,“Your request for help has been sent to Facebook.”,{ “OK” })   

                       

                 else

                         local response = json.decode( event.response )

                       

                        alert = native.showAlert(“Facebook Error”,response,{ “OK” }) 

                        

                  end

          end

end

facebook.login( appid, fblistener,{“publish_actions”} )

[/lua]

Bug submission: 31817

Hmm might be getting somewhere.  Seems like Facebook gets confused when permissions are turned off and on again.  

Just managed to post successfully without issue

Can you please ignore the bug submission please as I am getting there.  Was an issue with not resetting my settings>Facebook credentials each time for testing a new app. 

Bug submission: 31817

Hmm might be getting somewhere.  Seems like Facebook gets confused when permissions are turned off and on again.  

Just managed to post successfully without issue

Can you please ignore the bug submission please as I am getting there.  Was an issue with not resetting my settings>Facebook credentials each time for testing a new app. 

Hi,

SP, sorry but the code posted was using build 1262, we are aware that 2189 requires Facebook Plugin in build settings you mentioned. 

we have attached the code that we are using with build 1262, and the lines where the Facebook Listener is not getting called, hope this can help you understand our problem.

ui = require(“ui”)

local facebook = require “facebook”

require(“Json”)

local myText

local myText1

local appId = “272502539588566”;

local URL;

local function onClick( event )

myText.text = event.phase

if(event.phase == “release”) then

facebook.login( appId, listener, {“publish_stream”} )

end

end

function networkListener( event )

if ( event.isError ) then

myText.text = “networkListener error called”

myText2.text = response.id

else

     --here it is Comming and it is shown Connected in lable on Mobile Screen 

local info = event.response

local response = Json.Decode(event.response)

table.foreach(response,print)

print(#response)

myText.text = “networkListener called”

myText2.text = response.id

–requestId1 = network.request( URL,“GET”, networkListener1 )

end

end

function listener( event )

myText.text = event.token

    if ( “session” == event.type ) then

        if ( “login” == event.phase ) then

        myText2.text = event.phase

        myText.text = “Token” …event.token

           – facebook.request( “me/friends”, “GET” )

            

             facebook.request(“me”)                                                                                                           

            – Fetch access token for use in Facebook’s API

            print(“listeners”)

            --access_token = event.token

            myText.text = “Token” …event.token

            myText2.text = “Token2” …event.token

URL = "http://ourwebsite.com/createuser.php?token="…event.token…"&score=10"

network.request( URL,“POST”, networkListener )

( This line where the call is made to the function networkListener is where the code stops to respond and does not go to the function )

        end

    elseif ( “request” == event.type ) then

        local response = Json.Decode( event.response )

local data = response.data

local function showImage( event )

event.target.alpha = 0

event.target.xScale = 0.25

event.target.yScale = 0.25

            transition.to( event.target, { alpha = 1.0 , xScale = 1, yScale = 1} )

end

for i=1,#data do

display.loadRemoteImage(“http://graph.facebook.com/”… data[i].id …"/picture",

“GET”,

showImage,

“friend”…i…".png", 

system.TemporaryDirectory,

math.random(0,display.contentWidth),

math.random(0,display.contentHeight) )

end

    end

end

local myButton = ui.newButton {

        defaultSrc = “fb.png” , defaultX = “300” , defaultY = “50”,

        onEvent = onClick,

        id = “myButton”

}

myButton.x = display.contentWidth / 2

myButton.y = display.contentHeight / 2

myText = display.newText( “Hello World!”, 100, 200, native.systemFont, 16 )

myText2 = display.newText( “Hello World!”, 100, 300, native.systemFont, 16 )

–myText:setFillColor( 1, 0, 0 )

Sunil

Hi,

Rob we are joining the BETA testing group on Facebook so that developers with corona and IOS 7 can help us replicate the issue at their end and solve also. 

Thanks for all the help. :slight_smile:

Sunil

Hi,

SP, sorry but the code posted was using build 1262, we are aware that 2189 requires Facebook Plugin in build settings you mentioned. 

we have attached the code that we are using with build 1262, and the lines where the Facebook Listener is not getting called, hope this can help you understand our problem.

ui = require(“ui”)

local facebook = require “facebook”

require(“Json”)

local myText

local myText1

local appId = “272502539588566”;

local URL;

local function onClick( event )

myText.text = event.phase

if(event.phase == “release”) then

facebook.login( appId, listener, {“publish_stream”} )

end

end

function networkListener( event )

if ( event.isError ) then

myText.text = “networkListener error called”

myText2.text = response.id

else

     --here it is Comming and it is shown Connected in lable on Mobile Screen 

local info = event.response

local response = Json.Decode(event.response)

table.foreach(response,print)

print(#response)

myText.text = “networkListener called”

myText2.text = response.id

–requestId1 = network.request( URL,“GET”, networkListener1 )

end

end

function listener( event )

myText.text = event.token

    if ( “session” == event.type ) then

        if ( “login” == event.phase ) then

        myText2.text = event.phase

        myText.text = “Token” …event.token

           – facebook.request( “me/friends”, “GET” )

            

             facebook.request(“me”)                                                                                                           

            – Fetch access token for use in Facebook’s API

            print(“listeners”)

            --access_token = event.token

            myText.text = “Token” …event.token

            myText2.text = “Token2” …event.token

URL = "http://ourwebsite.com/createuser.php?token="…event.token…"&score=10"

network.request( URL,“POST”, networkListener )

( This line where the call is made to the function networkListener is where the code stops to respond and does not go to the function )

        end

    elseif ( “request” == event.type ) then

        local response = Json.Decode( event.response )

local data = response.data

local function showImage( event )

event.target.alpha = 0

event.target.xScale = 0.25

event.target.yScale = 0.25

            transition.to( event.target, { alpha = 1.0 , xScale = 1, yScale = 1} )

end

for i=1,#data do

display.loadRemoteImage(“http://graph.facebook.com/”… data[i].id …"/picture",

“GET”,

showImage,

“friend”…i…".png", 

system.TemporaryDirectory,

math.random(0,display.contentWidth),

math.random(0,display.contentHeight) )

end

    end

end

local myButton = ui.newButton {

        defaultSrc = “fb.png” , defaultX = “300” , defaultY = “50”,

        onEvent = onClick,

        id = “myButton”

}

myButton.x = display.contentWidth / 2

myButton.y = display.contentHeight / 2

myText = display.newText( “Hello World!”, 100, 200, native.systemFont, 16 )

myText2 = display.newText( “Hello World!”, 100, 300, native.systemFont, 16 )

–myText:setFillColor( 1, 0, 0 )

Sunil

Hi,

Rob we are joining the BETA testing group on Facebook so that developers with corona and IOS 7 can help us replicate the issue at their end and solve also. 

Thanks for all the help. :slight_smile:

Sunil