Invalid Parameter

Hi,

I’ve copy/pasted the FB v4 code from the sample app, and made basic modifications to suit my app.

It seems to work fine, but a post to facebook fails with the following output:

I/Corona  (28159): Facebook Already logged in with needed permissions

I/Corona  (28159): Printing table       true

I/Corona  (28159): --------------------------------

I/Corona  (28159): {

I/Corona  (28159):   “appId”:“188128428059002”,

I/Corona  (28159):   “declinedPermissions”:[],

I/Corona  (28159):   “expiration”:1486260025,

I/Corona  (28159):   “grantedPermissions”:[“public_profile”,“publish_actions”,“contact_email”,“user_friends”,“email”],

I/Corona  (28159):   “lastRefreshed”:1481098559,

I/Corona  (28159):   “token”:“EAACrGhAgaXoBAIOSZAUUAGqLdFKCQ0rOfhS6CnKjnjKgaKx8afhaARQHw1QoZAOwBpfhGdkzHww5p0x3CNZAGHB2VfZBEuu2cJ7VWNH4Mga5G5EC743WXAmhR23mA0CqNUqJmXXenh0kgd5nD9h81tNSdWxmFrv1iqwAEf1H8w5Gwi8qzIZBXK6PZCOaJjNxbTRHwZABhVjJgZDZD”,

I/Corona  (28159):   “userId”:“519676806”

I/Corona  (28159): }

I/Corona  (28159): Facebook in process fb command with rfc 1

I/Corona  (28159): Facebook posting message I’ve just started The Best Cricket Game Ever.  My team Australia is up against New Zealand.  Australia won the toss and elected to bat on a great batting wicket.  The players are now off to the middle to start the action.  If you’d like to play, download it in the Itunes App Store or Google Play Store:

I/Corona  (28159): http://www.bestcricketgame.com/download

I/Corona  (28159): Facebook got response :

I/Corona  (28159): Printing table       true

I/Corona  (28159): WARNING: attempt to print a non-table. Table expected, got nil

I/Corona  (28159): Facebook Listener events:

I/Corona  (28159): Facebook got event type : request

I/Corona  (28159):    type(request)

I/Corona  (28159):    name(fbconnect)

I/Corona  (28159):    didComplete(false)

I/Corona  (28159):    isError(true)

I/Corona  (28159):    response(Invalid parameter)

I/Corona  (28159): Facebook event.name  fbconnect

I/Corona  (28159): Facebook event.type: request

I/Corona  (28159): Facebook isError: true

I/Corona  (28159): Facebook didComplete: false

I/Corona  (28159): Facebookresponse: Invalid parameter

I/Corona  (28159): Printing table       true

I/Corona  (28159): WARNING: attempt to print a non-table. Table expected, got string

So the main thing is “Invalid Parameter”.

My processFBCommand() was altered as follows:

local function processFBCommand( )

local response = {}

print("Facebook in process fb command with rfc " … tostring(requestedFBCommand))

– This code posts a message to your Facebook Wall

if requestedFBCommand == POST_MSG then

print("Facebook posting message " … message)

response = facebook.request( “me/feed”, “POST”, message ) – posting the message

– This code posts a link to your Facebook Wall with a message about it

– This displays a Facebook Dialog to requests friends to play with you

elseif requestedFBCommand == SHOW_REQUEST_DIALOG then

print("Facebook showing friends request dialogue with message " … message)

response = facebook.showDialog( “requests”, { 

title = “Choose Friends to Play With”,

                    message = message,

                })

else

print(“Facebook No facebook command!”)

end

print("Facebook got response : " )

printTable( response )

end

You can see from the ADB output what the message parameter was, however I’ve also tried with a simple “this is a test” message which also failed with the same reason.

Any clues as to what the problem is, or is it possible to get more detailed debugging information from somewhere?

thanks!

Hi editor,

It looks like the message parameter you’re passing to facebook.request() is just a String. The expected parameter passed to that API is actually a Lua table where you can specify as many or as few optional parameters to facebook.request() as you like.

Here’s the bit of documentation that describes the options table: https://docs.coronalabs.com/plugin/facebook-v4/request.html#params-optional

And here’s the original bit of code from the sample you modified, which demonstrates usage of the options table:

-- ... -- This code posts a message to your Facebook Wall if requestedFBCommand == POST\_MSG then local time = os.date("\*t") local postMsg = { message = "Posting from Corona SDK! " .. os.date("%A, %B %e") .. ", " .. time.hour .. ":" .. time.min .. "." .. time.sec } response = facebook.request( "me/feed", "POST", postMsg ) -- posting the message -- ...

Hi editor,

It looks like the message parameter you’re passing to facebook.request() is just a String. The expected parameter passed to that API is actually a Lua table where you can specify as many or as few optional parameters to facebook.request() as you like.

Here’s the bit of documentation that describes the options table: https://docs.coronalabs.com/plugin/facebook-v4/request.html#params-optional

And here’s the original bit of code from the sample you modified, which demonstrates usage of the options table:

-- ... -- This code posts a message to your Facebook Wall if requestedFBCommand == POST\_MSG then local time = os.date("\*t") local postMsg = { message = "Posting from Corona SDK! " .. os.date("%A, %B %e") .. ", " .. time.hour .. ":" .. time.min .. "." .. time.sec } response = facebook.request( "me/feed", "POST", postMsg ) -- posting the message -- ...