Bertrand Posted October 9, 2013 Share Posted October 9, 2013 (edited) Hi, I'm currently building an Android application that must connect to my Prestashop website. Here are the functionalities that I must develop : - Make the users able to login into my app using the same credentials as they have created on the website - Make new users able to create an account - Make the user able to see and edit his/her profile - Make the user able to buy some products directly from my app In order to do this, I've started to study the Prestashop Webservices. I've been through the different tutorials but I'm having some problem to figure out how to integrate the "login" functionality. Basically, I just want to check if the Webservice give me a "customer" object when I send a GET method like this : http://mywebsite.com/api/customers/?filter[email][email protected]&filter[passwd]=my_password The thing is that the "my_password" value is encrypted in order to be saved securely in the Prestashop database. Thus, in the above request, I need to encrypt, in my app, the user password in order to get the same encrypted value that the one saved in the Prestashop database. Does anyone know how the password is encrypted? Am I choosing the correct solution to develop the login functionality? Thanks, Bertrand Edited October 9, 2013 by Bertrand (see edit history) Link to comment Share on other sites More sharing options...
Bertrand Posted October 9, 2013 Author Share Posted October 9, 2013 (edited) Ok I've found it The password is encode that way : md5( '_COOKIE_KEY_' + 'plain text password' ); See this thread for more information : http://www.prestashop.com/forums/topic/30984-password-encryption-psql-function/ The '_COOKIE_KEY_' is located in "settings/settings.inc.php" file of your prestashop folder Edited October 9, 2013 by Bertrand (see edit history) Link to comment Share on other sites More sharing options...
virtue Posted October 21, 2013 Share Posted October 21, 2013 (edited) hi, excuse me if i write here but i don't believe ii need open new topic. i'm in difficult because when i create a webservice with my prestashop i can't use it to interface with an app android beacuse it ask me the login, even if I insert the url http://my[email protected]/api/ . can you help me? thank you Edited October 21, 2013 by bit_dan (see edit history) Link to comment Share on other sites More sharing options...
Bertrand Posted October 22, 2013 Author Share Posted October 22, 2013 Hi, I also had troubles to figure out how to insert the API token in my HTTP requests. Here is the code that you have to use in order to be able to deal with the Prestashop WebServices in Android: First, create the DefaultHttpClient like this (API_AUTH_TOKEN is equal to your "mypasskey"): DefaultHttpClient client = new DefaultHttpClient(); AuthScope auth = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT); UsernamePasswordCredentials apiToken = new UsernamePasswordCredentials(API_AUTH_TOKEN, ""); client.getCredentialsProvider().setCredentials(auth, apiToken); Then use it as usual for your different HTTP Request. For instance, here is my method to send HTTP Get request /** * Generic HTTP GET method sender * HTTP GET must be used to retrieve informations from remote PrestaShop database * @param apiMethod * @return the server response as string. This response must be parsed. */ private String sendHttpGetMethod(String apiMethod){ String url = BASE_API_URL + "/" + apiMethod; HttpGet get = new HttpGet(url); HttpResponse responseGet; try { responseGet = client.execute(get); InputStream is = responseGet.getEntity().getContent(); BufferedReader r = new BufferedReader(new InputStreamReader(is)); StringBuilder response = new StringBuilder(); String line; while ((line = r.readLine()) != null) { response.append(line); } return response.toString(); } catch (ClientProtocolException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } } I hope this will help you, Bertrand Link to comment Share on other sites More sharing options...
virtue Posted October 22, 2013 Share Posted October 22, 2013 Thank you very very very to ansewr me. Sfortunatly i'm not expert and i need to know where insert that code. Thank you very much. Link to comment Share on other sites More sharing options...
Bertrand Posted October 23, 2013 Author Share Posted October 23, 2013 You might need to know a bit more about Android and calling RESTful webservice. Here is a good tutorial that might help you : http://www.techrepublic.com/blog/android-app-builder/calling-restful-services-from-your-android-app/ Link to comment Share on other sites More sharing options...
virtue Posted October 23, 2013 Share Posted October 23, 2013 I'm using app inventor and with a tutorial to read xml files. And my main problem is the login that prestashop asks at first. However i'll read it. Thank you very much. Link to comment Share on other sites More sharing options...
virtue Posted October 23, 2013 Share Posted October 23, 2013 (edited) ok, this is for eclipse. But it should be possible make an application with appinventor? i have no possibility to make it with eclipse. maybe with inventor I might be able to do something. Edited October 23, 2013 by bit_dan (see edit history) Link to comment Share on other sites More sharing options...
Karthik@123 Posted January 3, 2017 Share Posted January 3, 2017 Hello I actually have a doubt , how did u sort " Make new users able to create an account" using android ..? Advance thanks Link to comment Share on other sites More sharing options...
ambegaonkar.kanchan Posted May 4, 2017 Share Posted May 4, 2017 (edited) Hello I actually have a doubt , how did u sort " Make new users able to create an account" using android ..? Advance thanks Dealing with same issue please help with answer Edited May 4, 2017 by ambegaonkar.kanchan (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now