Tustin / psn-php

A PHP wrapper for the PSN API
https://tustin.dev/psn-php/
MIT License
353 stars 73 forks source link

[V3] Image download endpoint? #188

Closed Bornhall closed 2 years ago

Bornhall commented 2 years ago

Does anyone have the endpoint for, and know how to retrieve an image posted to a message thread?

Not looking to post an image, just getting it.

Posting an image to a thread, I've gotten the following in the message:

"messageDetail": {
    "imageMessageDetail": {
        "resourceId": "75c<16 hex chars>.<16 hex chars>_message_418840640297774_1636096251163"
    }
},

...where the two pairs of <16 hex chars> corresponds to the group id (as in ~<16 hex chars>.<16 hex chars>). Don't know where the "75c" part comes from, but I assume it's instead of the tilde character. The numeric part following "message" is unknown, but could simply be a kinda random numeric value. The last part looks to be a timestamp with microseconds.

I've tried accessing the /gameMediaService/v2/c2s/ugc/<UGC id>/url with set to various string combinations from the above resourceId, but only getting 404 not found in a JSON response, like this:

{"error":{"referenceId":"8126e6eb-3141-4214-b627-b224eb3aac6a","code":404,"reason":"document does not exist","message":"document does not exist","source":"shared_media"}}

Anyone had any luck with retrieving an image from the current API? I've tried snooping the traffic via a proxy to get at the endpoint URL, but as we know, normal SSL proxying prevents it from connecting.

Bornhall commented 2 years ago

Ok, this might be of interest to Tustin, I think I've found the endpoint to download images from a message thread:

/gamingLoungeGroups/v1/groups/ <threadId> /resources/ <resourceId>

Testing it now I got the test image I sent (a JPEG) just like that. The <threadId> is the message thread or group id, and <resourceId> is the entire string from the resourceId I mention in previous post, ending with the "_message_418840640297774_1636096251163" string.

To find this, I dug a bit and did a decompile of the Android version of the PlayStation app from the APK package, then started going through the code as good as I could. There are a lot more endpoints in the code if anyone is interested in browsing through it (searching for "/v1/" yields a lot for starters). I ran it through a javascript beautifier to make it readable, so it's now around 15 megabytes in size. Not sure posting it here is a great idea, but here's what you can do:

  1. Grabbed the APK for PlayStation app, version 21.10.1 from apkpure here: https://apkpure.com/playstation-app/com.scee.psxandroid
  2. Uploaded the APK file to http://www.javadecompilers.com/apk/
  3. Downloaded the resulting ZIP file.
  4. Inside the /resources/assets folder is a file named index.android.bundle
  5. Rename that file to .js and run it through a JS beautifier, I used https://beautifier.io/
  6. Save the beautified file somehwere and start browsing.
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.