1

I'm developing an app for Android for a woocommerce online shop. I want to work with Woocommerce API and authenticate with Http . I searched on the web , most of programmers are using PHP codes to connect to Woocommerce API and then get gson from those php code. is it any way to get gson from the Woocommerce API directly in android code? I'm using android studio. Tnx

Amin
  • 231
  • 4
  • 10
  • Use PHP for what? API calls? Surely you can put everything on Android side with something like this? https://github.com/BennSandoval/Woodmin – OneCricketeer Nov 17 '16 at 13:55
  • see my answer [here : WooCommerce API for mobile App](http://stackoverflow.com/questions/27489565/woocommerce-api-for-mobile-app/41526167#41526167) – ultra.deep Jan 07 '17 at 20:36

1 Answers1

1

There's no reason you can't contact the WC API directly from Android without needing to go through PHP. It will return a JSON object regardless of what language you use to contact it.

The better question is "why do the other programmers use PHP for it?" and there are two potential reasons for it.

The first reason is that they're developing a PHP platform so they're never sending the response onto an Android system so they'd only ever be using PHP.

The second reason is that it's much easier to update a PHP platform than it is to update an Android one. If you find yourself in a situation where you need to change how the API calls work but you can't guarantee that the Android platforms will all be updated in time (because you can never guarantee that) then it can be easier to have Android contact your own server which then passes the call onto the WC API.

For an example of the second scenario, let's assume that you're contacting http://exampleshop.com but they change over to using https for everything. Now you need to contact https://exampleshop.com but your app is still trying to contact http://exampleshop.com and will continue to do so until it receives your app update. In that situation, it'd be much easier to have the app contact http://yourserver.com and have your server contact https://exampleshop.com for the app. That way the URL and output will remain constant and you can make the required changes on your server which is much quicker and doesn't rely on every instance of your app receiving an update. This will mean that your app customers won't ever see your app breaking because of a change in the API.

Eligos
  • 1,104
  • 1
  • 11
  • 26