Determining Available Properties of API's

I started using the social plug in. Trying to get facebook sharing to work.

So I set the options to 

local options = {

    service = “facebook”,

    message = “Check out hello Words on the Google Play Store!”,

    listener = foo,

    url = "https://play.google.com/store/apps/details?id=com.helloagaingames.havochare.Hello_Words&hl=en"

}

And have created a listener foo

function foo(x)

end

So I am wondering… how do you determine what parameters are available for x, and what properties are available for x?

Is event always available? Is there a way to print off what properties are available for event in respect to the 

API you are using? I looked through the API reference but do not see the social plugin listed so I am not sure what Im getting back from the listener.

Hi @havochare4,

Well, first thing is that the typical way we specify “event” is not necessarily a strict rule. For example, in a listener function, the first argument can be any (legal) name that you want. For example, in these three functions, “event”, “x”, and “e” are the same thing from a Lua perspective:

[lua]

local function foo1( event )

end

local function foo2( x )

end

local function foo3( e )

end

[/lua]

Typically, Corona examples use “event” but this is not a strict rule, it’s just more descriptive and it’s for better consistency.

Now, whatever you call it, in a listener function you can typically use a Lua pairs() iteration to get the key-values contained inside that object, assuming it’s a Lua “dictionary style” table, which it will often be, but not always… it depends on what the API is sending over to the listener function.

[lua]

local function foo( event )

   for k,v in pairs( event ) do

      print( k,v )  – k=key, v=value

   end

end

[/lua]

Hope this helps,

Brent

Yes that’s what I was looking for, thanks!

<havochare4>: I may be mistaken, but it seems as though you’re trying to use the social plugin to share via Facebook under Android (I gather this from your mention of the Google Play Store).

This will not work. First, the service=“facebook” table entry is for iOS only, as the SDK docs note: http://docs.coronalabs.com/plugin/CoronaProvider_native_popup_social/showPopup.html

Second, in theory you should be able to use the social plugin to share via the standard Android intents mechanism. But this is broken in Corona. Some of us have been trying to get Corona to fix Android Facebook sharing for about half a year, and there are some signs it may happen soon, but the fix has not yet made it to a daily build. See discussion here: http://forums.coronalabs.com/topic/52755-can-corona-enable-limited-facebook-sharing-on-android-via-nativeshowpopup/

If I’ve correctly diagnosed your problem, you may want to post there to let folks know this is important.

Yeah I did see that post, and yes that is what I am trying to accomplish. I agree it is important and hope to see it  fixed soon.  

Yep. I even tried a naked bribe in the form of baked goods delivered to Corona HQ in Palo Alto – if Android Facebook sharing were fixed by the end of March, something like 5 months after fall 2014 discussion thread started. Alas, the deadline came and went!

Hi @havochare4,

Well, first thing is that the typical way we specify “event” is not necessarily a strict rule. For example, in a listener function, the first argument can be any (legal) name that you want. For example, in these three functions, “event”, “x”, and “e” are the same thing from a Lua perspective:

[lua]

local function foo1( event )

end

local function foo2( x )

end

local function foo3( e )

end

[/lua]

Typically, Corona examples use “event” but this is not a strict rule, it’s just more descriptive and it’s for better consistency.

Now, whatever you call it, in a listener function you can typically use a Lua pairs() iteration to get the key-values contained inside that object, assuming it’s a Lua “dictionary style” table, which it will often be, but not always… it depends on what the API is sending over to the listener function.

[lua]

local function foo( event )

   for k,v in pairs( event ) do

      print( k,v )  – k=key, v=value

   end

end

[/lua]

Hope this helps,

Brent

Yes that’s what I was looking for, thanks!

<havochare4>: I may be mistaken, but it seems as though you’re trying to use the social plugin to share via Facebook under Android (I gather this from your mention of the Google Play Store).

This will not work. First, the service=“facebook” table entry is for iOS only, as the SDK docs note: http://docs.coronalabs.com/plugin/CoronaProvider_native_popup_social/showPopup.html

Second, in theory you should be able to use the social plugin to share via the standard Android intents mechanism. But this is broken in Corona. Some of us have been trying to get Corona to fix Android Facebook sharing for about half a year, and there are some signs it may happen soon, but the fix has not yet made it to a daily build. See discussion here: http://forums.coronalabs.com/topic/52755-can-corona-enable-limited-facebook-sharing-on-android-via-nativeshowpopup/

If I’ve correctly diagnosed your problem, you may want to post there to let folks know this is important.

Yeah I did see that post, and yes that is what I am trying to accomplish. I agree it is important and hope to see it  fixed soon.  

Yep. I even tried a naked bribe in the form of baked goods delivered to Corona HQ in Palo Alto – if Android Facebook sharing were fixed by the end of March, something like 5 months after fall 2014 discussion thread started. Alas, the deadline came and went!