0

Can i login to EE website from another device, ie iOS device. Basically i have a website with users, i need to login to it from a mobile phone application. Is it possible? I know that EE server generates XID entry for protection Is there any way around it?

We are developing an iOS application and trying to register member to the Member Group by providing fields(screen name, password, confirm password, email), we are planning to post these variables to php script and insert it into the ee database table(s). What are these tables ? Is there any place we can se examples of php script? what else do we need to consider?

  • Are you trying to do something specific? More a point of clarification, since standard logging in to an EE site and even the EE control panel works perfectly fine on iOS. I work in the control panel from my iPad frequently. – nonprofit_tech Dec 17 '12 at 8:11
  • Thanks for your quick reply, we creating an application that basically will be using logging in to EE – Tim Dec 17 '12 at 8:53
  • Sorry but it's still not very clear. What are you trying to do exactly? – pvledoux Dec 17 '12 at 10:17
  • +1 that you need to add more information about exactly what you're trying to do. What are you doing once users are logged in? If you want to edit content, how are do you want to do so etc? – Tom Davies Dec 17 '12 at 10:46
  • 1
    Do you want to programmatically authenticate a user to a native iOS app, or are you wanting to use Safari to access your app? The two processes are radically different. – Justin Kimbrell Dec 17 '12 at 13:59
3

I think this question is a little vague, you need to clarify what exactly you are trying to do. I'd also question whether EE makes a good backend for any sort of mobile app, you are probably better off writing your own backend app directly in PHP, or looking at something like Parse, however, I digress.

The principles are simple enough. This has already been done by Mountee, for example. To log in to EE from a native app, there are three steps:

  1. Generate an XID (just request the login page, and parse the response to get an XID value). If you create your own PHP login script you can avoid this requirement.
  2. Submit the login form
  3. Record the session cookie in your app and use it for future requests

As far as actually creating new members in the database - it is best to use the built in EE functions as much as possible for this. The EE member API is a bit of a minefield, and wasn't written with re-use in mind. However, with some tricks it is possible to call the functions and avoid any issues which may arise from changes to the database schema in future.

Your best starting point is probably to take a look at the open source Freemember plugin, which allows you to create front-end member registration & login forms. You could also use its library which abstracts the process of registering new members.

| improve this answer | |
  • Thank you for your reply. We are developing an iOS application and trying to register member to the Member Group by providing fields(screen name, password, confirm password, email), we are planning to post these variables to php script and insert it into the ee database table(s). What are these tables ? Is there any place we can se examples of php script? what else do we need to consider? – Tim Dec 18 '12 at 11:53
  • I've updated my answer with more information :) – Adrian Macneil Dec 18 '12 at 23:10
2

A more programatic approach to this could involve creating an ACTion URL. There is not much documentation about them except to read through the EE codebase, but these URLs could remove the need to deal with XIDs.

From http://ellislab.com/expressionengine/user-guide/development/module_tutorial.html:

$data = array(
    'class'     => 'Download' ,
    'method'    => 'force_download'
);
$this->EE->db->insert('actions', $data);

Note that the method has to be inside of a class in either your mod.extension.php or mcp.extension.php files. You access them like this:

http://www.example.com/?ACT=21

Where the number after ACT is the row ID from the "exp_actions" table that references your class and function.

With this you will have a partially-loaded EE environment so that you can register users (or check login credentials) through the appropriate methods. I do recommend using SSL and also rate-limiting requests through this interface.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.