News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

SMF Login in Unity

Started by fariel, July 09, 2015, 04:12:52 PM

Previous topic - Next topic

fariel

Okay, this one is a little weird compared to everything I've read here. I'm looking to allow users to log in to their forum account via a form in Unity.  The idea is that in Unity, there is a field for email and password. Typing that in sends the email and password to a php file that tries to log the user in. If it fails, it returns "Invalid username/password" (and nothing else, because I have to pull the data it returns in Unity to display in a text object) and if it succeeds, returns a generated xml file with the user's username, avatar url, and then some kind of session ID or cookie or something for security purposes and knowing if the user is still logged in.

The majority of this is easy. The part that trips me up is actually logging in.  I'm not sure how to write a php login script that just takes the email and password and tries it. Can anyone point me in the right direction?


Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

margarett

From your description, maybe the API written by AndreN sticky in this board
http://www.simplemachines.org/community/index.php?topic=453008.0

Never used it myself but the topic has some neat explanations ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

fariel

I actually saw this reply coming. I've looked in to the SSI file and the login and login2 functions.  The part that has me confused is how I can send the login information to these functions with a custom form (i.e. one built in Unity). Am I missing something?

*edit: @margarett: I just looked in to that again. I overlooked the login functions earlier.  Will try that and return if it doesn't work out.  Thanks.

margarett

You can't by using SSI.php
Which is why I pointed you to AndreN's API, as it has a login/logout function ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

fariel

Playing around with this, I'm working under the assumption that I need to use smfapi_authenticate on the username/pass combo and, if it returns true, I call smfapi_login with the same combo and that logs the user in.

My assumption is that I can then pull any information I need from user_info?
How long does the user stay logged in for? 
If they close and reopen the program, is there a way that I can store the session info so that they can remain logged in?

Confession: My php is a little shaky. It's not the programming part of it that's shaky, it's the whole web thing that gets me turned around. Sessions and whatnot. I have a lot of trouble wrapping my head around the reliability of web-based things.

margarett

Unfortunately I can't really help you as never used it, I just know it exists and more or less what it does. Try to search the topic, maybe some of that is already answered there...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Kindred

well, the link that I gave you points to THREE different methods of integration... not just SSI.

SSI.php (not appropriate for your implementation
hooks (probably not appropriate, since it depends on SMF being the primary interface)
and API (both normal and RESTful)

All three methods are described, in some amount of detail in that link that I gave you (which links to the CATEGORY, not an individual method)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: