Sematre / DSBmobile-API

A simple Java library for DSBmobile
MIT License
19 stars 2 forks source link

Web interface issues #3

Closed LCLPYT closed 4 years ago

LCLPYT commented 5 years ago

Recently I noticed that you upgraded your API, but it sadly isn't working for me.

Your API lacks some crucial steps while pulling the data. I forked your project a while ago to implement the new DSB web interface. (https://github.com/LCLPYT/DSBmobile-API)

It is working fine for me and I suggest you to take a look. Maybe it could help you to improve your original version too. I wanted to submit a pull request, but I think mine differs to much to be merged with yours.

Keep up the great work 👍

Sematre commented 5 years ago

Coud you explane a little bit futher what exactly isn't working? Is there some kind of error or something similar?

I took a look at your fork, but it seems like the main difference between your fork and my code is that your code uses the web api while my code uses the app api.

LCLPYT commented 5 years ago

Yesterday I ended up with a FileNotFoundException, but as it turns out, I was not using the latest version of your API. But after building the latest version from your source, it is working again. Sorry for the inconvenience.

And yes, I now recognize the slightly different URL in your source. I think you took the easier path using the App API, since the Web API seems to change it's structure daily...

Thank you

LCLPYT commented 5 years ago

Okay I am sorry but I think a new error occured:

Exception in thread "main" java.lang.NullPointerException: Server response doesn't contain content! at java.util.Objects.requireNonNull(Objects.java:228) at de.sematre.dsbmobile.DSBMobile.getTimeTables(DSBMobile.java:53) at work.lclpnet.dsbtest.DSBTest.main(DSBTest.java:13)

My code:

public static void main(String[] args) {
    DSBMobile dsb = new DSBMobile(args[0], args[1]);
    List<TimeTable> timeTables = dsb.getTimeTables();
    System.out.println(timeTables);
}

Sometimes it works and sometimes it throws the error above.

nerrixde commented 5 years ago

My DSB API is also broke, they changed their endpoints. I am currently reverse engineering their js configuration file (they obfuscated it) in order to get a idea how to implement their "API".

LCLPYT commented 5 years ago

I have the same problem with the Web Interface. I can't even open my developer tools. They seem to block it

Sematre commented 5 years ago

@LCLPYT I'm aware of that bug. This exeption is thrown when your login credentials are wrong or when the server rejects your request.

nerrixde commented 5 years ago

@Sematre nah, they implemented a developer-tools-block (which is easy to bypass, just disable debugging) and moreover they changed their endpoint. Please comment here: https://github.com/nerrixDE/DSBApi/commit/9c17f0cf13826c6b30cacb42d7ffc5ae93dc0246#r35652274

LCLPYT commented 5 years ago

@Sematre I see you have implemented the content request exactly the way as the DSBMobile App does. May I ask what the unescapeString() method does? I can't seem to find it anywhere in the original code...

Sematre commented 5 years ago

@LCLPYT Ok, so my problem was, that the toJson() method in the Gson lib, retuned escaped Json (e.g. {\"foo\":\"Bar\"}). The unescapeString() method unecapes the json string. The result woud be e.g. {"foo":"Bar"}

Note: This dosn't happen every time, but to be on the safe side, I'll do it anyway.

LCLPYT commented 5 years ago

@nerrixDE maybe this is a bit off topic, but could you give me a hint how to bypass the developer-tools-block? Which browser are you using by the way? It would make reverse engineering much easier. Thanks in advance

mammut53 commented 5 years ago

I have the feeling that they (heinekingmedia GmbH) really do not want us to mess with their endpoints. 😂

nerrixde commented 5 years ago

@LCLPYT as I don't use the WEB-Api anymore I turned off Debugging in Firefox globally in order to be able to log requests. An other option is to switch to a different browser or open the dev-tools right after the catch of the breakpoint. Also sniffing via Fiddler, Mitmproxy, Burp or Wireshark is still possible.