Can anyone help me create this extension?

api.streamtape.com/file/info?file=o9bRbqaa78sJJ3K

Runtime Error

call to 'Teste1$Result' has too many arguments (4; must be 3)
Note: You will not see another error reported for 5 seconds.

I would like help creating this block

public void FetchData(final String login, final String key, final String id) {
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                String apiUrl = "https://api.streamtape.com/remotedl/status?login=" + login + "&key=" + key + "&limit={limit}&id=" + id;
                URL url = new URL(apiUrl);
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                connection.setRequestMethod("GET");
                connection.setConnectTimeout(5000);
                connection.setReadTimeout(5000);

                int responseCode = connection.getResponseCode();
                if (responseCode == HttpURLConnection.HTTP_OK) {
                    InputStream inputStream = connection.getInputStream();
                    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
                    StringBuilder response = new StringBuilder();
                    String line;
                    while ((line = reader.readLine()) != null) {
                        response.append(line);
                    }
                    reader.close();
                    inputStream.close();

                    JSONObject jsonResponse = new JSONObject(response.toString());
                    final String status = jsonResponse.getString("status");
                    final String msg = jsonResponse.getString("msg");
                    final String id = jsonResponse.getString("id");
                    
                    // Pass the full response as a parameter
                    final String fullResponse = response.toString();

                    Handler handler = new Handler(context.getMainLooper());
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            Result(status, msg, id, fullResponse);
                        }
                    });
                } else {
                    Handler handler = new Handler(context.getMainLooper());
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            Result("Error", "API request failed", "", "");
                        }
                    });
                }
            } catch (final Exception e) { // Declare e as final here
                Handler handler = new Handler(context.getMainLooper());
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        Result("Error", e.getMessage(), "","");
                    }
                });
            }
        }
    }).start();
}

public void Result(
        String status,
        String msg,
        String id,
        String fullResponse) {
    EventDispatcher.dispatchEvent(this, "Result", status, msg, id, fullResponse);
}

}

1 Like
  1. the source code and the ai2 blocks do not match. Result function in source code have 4 params, but in thr blocks 6 params.

  2. you don't need the annotation like @SimpleFunction, @Simple Event?

this limit param working like this ?

  1. Did you disconnect and reconnect your Ai2 companion after update the extension?
1 Like

I've tried several times but it always goes wrong

show your code and error message.

EventDispatcher.dispatchEvent(this, "Result", status, msg, id, remoteurl, bytes_loaded, bytes_total, folderid, added, last_update, last_update, linkid, fullResponse);
    }

You used "last_update" twice. Additionally, if you want to publish this extension to this community, you must follow the naming convention. Not "ladt_update" but lastUpdate"

1 Like

Why an extension, just use the web component?
(or at least build with the web component, this might throw some light on why your extension is not working...)

1 Like

This extension is going to reduce more than a thousand, blocks of my project

really?

yes, Help me 'cause I'm having a hard time

Try this:

            String fullResponse = response.toString();
            JSONObject jsonResponse = new JSONObject(fullResponse);
            String status = jsonResponse.getString("status");
            String msg = jsonResponse.getString("msg");
            JSONObject result = jsonResponse.getJSONObject("result");
            String id = result.keys().next();
            JSONObject resultObject = result.getJSONObject(id);
            String remoteurl = resultObject.getString("remoteurl");
            String bytesLoaded = resultObject.getString("bytes_loaded");
            String bytesTotal = resultObject.getStringt("bytes_total");
            String folderId = resultObject.getString("folderid");
            String added = resultObject.getString("added");
            String lastUpdate = resultObject.getString("last_update");
            String linkId = resultObject.getString("linkid");

Is there a guide or template that helps me learn how to use the web component from an extension? (code)

I would like to make an extension that uses the web component to POST to an API, but I want to securely store the Apikey and URL of the project.

(it would really take a lot of blocks off my shoulders).

Use the web component together with the Obfuscate block from the text drawer to secure your Apikey and url...
Creating an extension will not offer better security...

Taifun

1 Like

Thanks Taifun.

  • After much reading and testing, I realized that it is work in vain to try to protect the device, the data inside it... it is another topic I use the Keystore extension before saving the values ​​in TinyDB.
  1. We tried all kinds of ROOT, USB, ADB measures, but the Apk can still be extracted for reverse engineering. [And it is not always possible to detect root]

  2. We tried with Shell commands, but it gave us problems when uploading the App to the PlayStore (issues with code inspection and other Google security issues)

  3. We also tried with JS and extended WebViwer, but it could still be bypassed.

  4. We tried downloading Shell & JS files from the backend, to be executed, but it requires giving permissions to execute, so it does not serve as a measure or countermeasure.

  5. Once the App was extracted and reverse engineered, the Apikey and URL could be extracted before being encrypted [start screen1 > keystore.encrypt: My_Apikey & URL: My_Project] because they are stored in the code

  • So the focus changed to securing the backend as much as possible [we chose Postgre] and avoiding MITM attacks.

  • This coming week, we will test how easy it is to steal data when it is decrypted and loaded into device memory (before being encrypted and sent), as well as MITM attacks to see how the API and database behaves [triggers, functions, user roles, row level security, views, tables, policies, etc.].

  • I hope someone finds this information useful.

1 Like

Did you use the Obfuscated block?
http://ai2.appinventor.mit.edu.ezproxy.canberra.edu.au/reference/blocks/text.html#obfuscatetext

Taifun

1 Like

Yes.