MediaFire

From Christoph's Personal Wiki
Revision as of 21:17, 27 May 2015 by Christoph (Talk | contribs) (New page: '''MediaFire''' is a file hosting, file synchronization, and cloud storage service. ==MediaFire API== * Step #1: Create environment variables: $ MF_ENDPOINT="<nowiki>https://www.mediaf...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

MediaFire is a file hosting, file synchronization, and cloud storage service.

MediaFire API

  • Step #1: Create environment variables:
$ MF_ENDPOINT="https://www.mediafire.com/api/1.3"
$ MF_EMAIL=<YOUR_MEDIAFIRE_ACCOUNT_EMAIL>
$ MF_PASSWORD=<YOUR_MEDIAFIRE_ACCOUNT_PASSWORD>
$ MF_APP_ID=<YOUR_MEDIAFIRE_APPLICATION_ID>
$ MF_API_KEY=<YOUR_MEDIAFIRE_API_KEY>
$ MF_SIGNATURE=`python -c "import hashlib;print(hashlib.sha1('${MF_EMAIL}${MF_PASSWORD}${MF_APP_ID}${MF_API_KEY}')).hexdigest()"`
$ MF_QUERY_PARAMS="email=${MF_EMAIL}&password=${MF_PASSWORD}&application_id=${MF_APP_ID}&signature=${MF_SIGNATURE}"
$ curl -s "${MF_ENDPOINT}/user/get_session_token.php?${MF_QUERY_PARAMS}&response_format=json" |\
    python -mjson.tool
# RESPONSE:
{
    "response": {
        "action": "user/get_session_token",
        "current_api_version": "1.3",
        "ekey": "<REDACTED>",
        "pkey": "<REDACTED>",
        "result": "Success",
        "session_token": "<REDACTED>"
    }
}
  • Grab your session token from the response above and set:
$ MF_TOKEN=fffff  # 144 alphanumeric string of characters (valid for 10 minutes)
  • Get user's basic account information:
$ curl -s "${MF_ENDPOINT}/user/get_info.php?session_token=${MF_TOKEN}&response_format=json" | python -mjson.tool
# RESPONSE:
{
    "response": {
        "action": "user/get_info",
        "current_api_version": "1.3",
        "result": "Success",
        "user_info": {
            "bandwidth": "0",
            "base_storage": "16106127360",
            "birth_date": "",
            "bonus_storage": "39728447488",
            "created": "2010-11-22",
            "display_name": "Bob Brown",
            "ekey": "<REDACTED>",
            "email": "bob@example.com",
            "facebook": {
                "linked": "no"
            },
            "first_name": "Bob",
            "gender": "Male",
            "gmail": {
                "linked": "no"
            },
            "last_name": "Brown",
            "location": "",
            "one_time_key_request_max_count": "10",
            "options": "0",
            "premium": "no",
            "storage_limit": "55834574848",
            "storage_limit_exceeded": "no",
            "tos_accepted": "",
            "twitter": {
                "linked": "no"
            },
            "used_storage_size": "123456789",
            "validated": "yes",
            "website": "http://www.example.com"
        }
    }
}
$ echo 55834574848/1024^3 | bc -l  # => storage_limit = 52 GB

External links