ibisis

    Hi,

     

    I would like to use wget or curl in a script to obtain the data usage and number of days left for a T-Mobile data line.

     

    I know there are a couple of interactive ways to get data usage via SMS or from the T-Mobile website.  This is for a remote computer connected by Ethernet to a cellular modem that could better manage its Internet access if it could query for data usage and days left.

     

    1) Is there a special URL that returns mainly those results without the verbiage aimed at an interactive user?

     

    2) If not, does anyone have an example of using wget or curl, or a script, that can be used to login to a T-Mobile account, get the data usage web page, and parse it for the just the data usage/days left?

     

    I have tried:

       wget https://my.t-mobile.com/usage/usageoverview.html

    and got back a web page that maybe is telling me that cookies are not enabled and asking for a username/password.

     

    The wget documentation has information that might work describing a process involving two wget calls:

    1) one wget call to login:

            wget --save-cookies cookies.txt \

               --post-data 'user=foo&password=bar' \

                 http://server.com/auth.php

    2) and a second call to get the data:

           # Now grab the page or pages we care about.

            wget --load-cookies cookies.txt \

               -p http://server.com/interesting/article.php

     

    To find the authorization URL I looked at a login screen that T-Mobile presented to me:

    https://account.t-mobile.com/oauth2/v1/auth?redirect_uri=https%3A%2F%2Fmy.t-mobile.com&scope=TMO_ID_profile%20associated_lines%20billing_information&client_id=A-3amGd14-iz0&access_type=ONLINE&response_type=code&approval_prompt=auto&state=true" title="https://account.t-mobile.com/oauth2/v1/auth?redirect_uri=https%3A%2F%2Fmy.t-mobile.com&scope=TMO_ID_profile%20associated_lines%20billing_information&client_id=<<<some_client_id>>>&access_type=ONLINE&response_type=code&approval_prompt=auto&state=true"

     

    Not as simple the the wget example.  There are redirects - is all of that URL necessary?   Also there is a "client id" that was automatically or previously generated?  Do I need a prior wget call to get a client id?

     

    I would appreciate help if anyone has already worked through this or knows what URL's and arguments to use?

     

    Thanks,

     

    Bill

      All replies

      • smplyunprdctble

        Re: how to get data usage using a script

        There's a lot of scripting that happens that pulls the usage information (if you open the site in your browser, you'll see the magenta dots in a circle).  I'd almost guess that it's not possible because of these.

         

        You may want to look into Fiddler to see if it can help you determine the requests that are being passed to and from to see if you can pick out the pieces you need.  There's no "official API", which appears to be what you're looking for.

         

        Be cautious, though, T-Mobile seems to be continuously changing the site.  There's a chance that what works today can get broken tomorrow.