Hi
I am having some issues getting a json call to work, I want to mimic the functionality
of a third party android app.
I used jadx to decompile the apk and get the source, but just can't seem to get it to work
even though I think I am sending the call as they do in the app, I dont do a lot of java.
The website allows you to sell media to them and they use a shopping basket system, looking a the
source when you start the app, it firsts checks if there is a basket open for you
using the following code :
Beaking the above code down, the json part seems to me to be sending
customerId
customerKey
with blank values, I take it this will make a request to create a new basket or pass back
any current basket open on their system ?
It calls putItemBasket() as part of the call
I take it doInBackground just creates a new thread ? but not to sure, the rest just looks
like an http call, but I am not sure about MainActivity.this.se.setContentType(OAuth.FORM_ENCODED);.
I want to send this request from B4A, and have tried various http request calls but keep getting
{"status":"ERROR","code":"GEN01","message":"The method you specified could not be found"}
but I have followed the source and think it can only be the json params that I am not sending
correctly ?
I would appriciiate any help with this, I do not really do a lot of Java programming, so I might
to missing something very basic !
Regards
Potman
I am having some issues getting a json call to work, I want to mimic the functionality
of a third party android app.
I used jadx to decompile the apk and get the source, but just can't seem to get it to work
even though I think I am sending the call as they do in the app, I dont do a lot of java.
The website allows you to sell media to them and they use a shopping basket system, looking a the
source when you start the app, it firsts checks if there is a basket open for you
using the following code :
B4X:
public void performBasketKeyLogin(boolean login) {
try {
this.se = new StringEntity("{\"customerId\":,\"customerKey\":}", Hex.DEFAULT_CHARSET_NAME);
JSONObject json_data = new JSONObject((String) new putItemBasket().execute(new String[]{new StringBuilder(String.valueOf(this.string_data.mainUrl())).append("offer/create/?apiKey=").append(this.string_data.appApiKey()).append("&site=").append(this.string_data.siteType()).toString()}).get());
if (json_data.getString("status").equalsIgnoreCase("ok")) {
setBasketDetails(json_data.getJSONObject("data").getString("basketId"), json_data.getJSONObject("data").getString("basketKey"));
}
} catch (Exception e) {
e.printStackTrace();
}
}
Beaking the above code down, the json part seems to me to be sending
customerId
customerKey
with blank values, I take it this will make a request to create a new basket or pass back
any current basket open on their system ?
It calls putItemBasket() as part of the call
B4X:
class putItemBasket extends AsyncTask<String, String, String> {
putItemBasket() {
}
protected String doInBackground(String... uri) {
HttpClient httpclient = new DefaultHttpClient(new BasicHttpParams());
try {
[b]MainActivity.this.se.setContentType(OAuth.FORM_ENCODED);[/b]
HttpPut httpget = new HttpPut(uri[0]);
httpget.setEntity(MainActivity.this.se);
HttpResponse response = httpclient.execute(httpget);
StatusLine statusLine = response.getStatusLine();
System.out.println("STATUS LINE >>> " + statusLine);
if (statusLine.getStatusCode() == ParseException.USERNAME_MISSING) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
response.getEntity().writeTo(out);
out.close();
return out.toString();
}
response.getEntity().getContent().close();
throw new IOException(statusLine.getReasonPhrase());
} catch (ClientProtocolException e) {
return null;
} catch (IOException e2) {
return null;
}
}
I take it doInBackground just creates a new thread ? but not to sure, the rest just looks
like an http call, but I am not sure about MainActivity.this.se.setContentType(OAuth.FORM_ENCODED);.
I want to send this request from B4A, and have tried various http request calls but keep getting
{"status":"ERROR","code":"GEN01","message":"The method you specified could not be found"}
but I have followed the source and think it can only be the json params that I am not sending
correctly ?
I would appriciiate any help with this, I do not really do a lot of Java programming, so I might
to missing something very basic !
Regards
Potman