Frustrating Parse/Facebook Issue

I noticed this on the Code Exchange comments a while back and now it’s come back to haunt me.

I’m trying to get Users who log-in via Facebook to be added to my Parse.com database.

The problem lies with Facebook returning a UNIX timestamp for expiration_date and Parse.com seemingly needing this in a SimpleDateFormat yyyy-MM-dd’T’HH:mm:ss.SSS’Z’

I’ve tried to convert the timestamp with os.date("*t", expiration_date), JSON the table and cocatenate the various elements into a string - however after a couple of hours getting nowhere I’m struggling with the frustration.

Does anybody know of a better way?

Always the case… solved it a few minutes after posting here. I think that’s why I always put a post - solution is never far behind :slight_smile:

In case anybody needs it - this really dirty hack seems to have done the job:

[lua]

local fbdate = os.date("*t", event.expiration)
print(json.encode(fbdate))
           

if fbdate.month < 10 then fbdate.month = “0”…fbdate.month end
           

local temp = fbdate.year…"-"…fbdate.month…"-"…fbdate.day…“T”…fbdate.hour…":"…fbdate.min…":"…fbdate.sec
print("temp: "…temp)
           
fbData.authData.facebook.expiration_date = temp

[/lua]

Always the case… solved it a few minutes after posting here. I think that’s why I always put a post - solution is never far behind :slight_smile:

In case anybody needs it - this really dirty hack seems to have done the job:

[lua]

local fbdate = os.date("*t", event.expiration)
print(json.encode(fbdate))
           

if fbdate.month < 10 then fbdate.month = “0”…fbdate.month end
           

local temp = fbdate.year…"-"…fbdate.month…"-"…fbdate.day…“T”…fbdate.hour…":"…fbdate.min…":"…fbdate.sec
print("temp: "…temp)
           
fbData.authData.facebook.expiration_date = temp

[/lua]

Question. 

I see how to create a parse account and I know how to connect that to my Corona App. 

I know how to integrate Facebook into the corona app. 

How do I connect the Facebook login to Parse?

Thx!

Question. 

I see how to create a parse account and I know how to connect that to my Corona App. 

I know how to integrate Facebook into the corona app. 

How do I connect the Facebook login to Parse?

Thx!

Hey mythinkhouse,

Did you ever figure this out.

Alberto

This is a case of where string.format() is your friend.

local myDate = string.format("%04d-%02d-%02dT%02d:%02d:%02s:%dZ",

           year, month, day, hour, minutes, seconds, tzoffset)

I’ll be posting about how to do the facebook login connection probably tomorrow.  In the meantime have a look at this if you can http://forums.coronalabs.com/topic/42191-a-parsecom-module-for-corona-sdk/

Cheers.

I wrote up an article about linking the Corona Facebook user to Parse.  It does us the mod_parse Corona SDK Parse module, but you can extract the information and use it without the mod.

Managing Facebook Users

Hope it helps.  Cheers.

Jedi,

You are awesome. Thank you very much. This is exactly what I needed.

Alberto

@Alberto Let me know if you run into any issues.  And if it works, please share it.

Cheers.

Hey mythinkhouse,

Did you ever figure this out.

Alberto

This is a case of where string.format() is your friend.

local myDate = string.format("%04d-%02d-%02dT%02d:%02d:%02s:%dZ",

           year, month, day, hour, minutes, seconds, tzoffset)

I’ll be posting about how to do the facebook login connection probably tomorrow.  In the meantime have a look at this if you can http://forums.coronalabs.com/topic/42191-a-parsecom-module-for-corona-sdk/

Cheers.

I wrote up an article about linking the Corona Facebook user to Parse.  It does us the mod_parse Corona SDK Parse module, but you can extract the information and use it without the mod.

Managing Facebook Users

Hope it helps.  Cheers.

Jedi,

You are awesome. Thank you very much. This is exactly what I needed.

Alberto

@Alberto Let me know if you run into any issues.  And if it works, please share it.

Cheers.