achievements-app / psn-api

A JavaScript library that lets you get trophy, user, and game data from the PlayStation Network.
https://psn-api.achievements.app
MIT License
263 stars 31 forks source link

Does psn provide an official api to send messages to friends? #133

Closed huazaizhang closed 1 year ago

huazaizhang commented 1 year ago

Does psn provide an official api to send messages to friends?

huazaizhang commented 1 year ago

I found on github that the psnjs(https://github.com/cubehouse/PSNjs/blob/master/psn_request.js) and psn-api-python(https://github.com/mgp25/psn-api/blob/master/psnapi/Messaging.py) projects mentioned using the following api:

MESSAGE_THREADS_URL = 'https://es-gmsg.np.community.playstation.net/groupMessaging/v1/threads' MESSAGE_USERS_URL = 'https://es-gmsg.np.community.playstation.net/groupMessaging/v1/users/' SEND_MESSAGE_URL = 'https://es-gmsg.np.community.playstation.net/groupMessaging/v1/messageGroups/'

I try to use my own account accessToken to access: https://hk-gmsg.np.community.playstation.net/groupMessaging/v1/users/tangy_crayon1/messageGroups

but returns:

{ "error": { "code": 2122246, "message": "Not authorized" } }

I don't know where is the problem? Is it because my account has not enabled this restriction, or Sony has disabled this function

huazaizhang commented 1 year ago

@wescopeland @travisrroy @Azimiao @isFakeAccount Have any of you encountered this problem and can give me some help?

TheYuriG commented 1 year ago

I suspect this API endpoint was disabled when Sony had a big influx of message spammers inviting users to join a telegram group to buy stolen PS4 accounts with games for a portion of the price. Or maybe it wasn't and it was moved to the .com domain since the .net domain was killed last year. Have you tried requesting to .com instead?

Also, your question is about official endpoints from Sony and I'm pretty sure nothing we use is official, it's all reverse-engineered from the apps or websites they have put out. Service provided by this (and probably every other similar library) can be interrupted at literally any moment.

There must still be a way to do it since that feature is available on the PS App for phones, but I don't think any of us found the endpoint to do it yet. As it is, is possible to do it and we just don't know how yet. #119 is about this very same thing, I believe.

If anyone else knows more, feel free to chime in (and possibly correct me).

huazaizhang commented 1 year ago

@TheYuriG Anyway thank you very much. I have add the robot of "https://ps-timetracker.com/", it can track my time and send it to me daily, I don't know how he achieves sending messages.

isFakeAccount commented 1 year ago

Like @TheYuriG mentioned, nothing here is official. All the endpoints are reversed engineered from PlayStation app. I don't think there ever will be an offical api, even if there is, it will be hidden behind a paywall or a developer program.

Now with that out the way, yes there are endpoints for sending messages to other users, I added them to my API wrapper https://github.com/isFakeAccount/psnawp quite a while ago. It supports text messages only for now.

If you are ok with python then you can use my api wrapper. Just try not to spam, otherwise Sony will find out and change the endpoint.

wescopeland commented 1 year ago

Closing in favor of https://github.com/achievements-app/psn-api/issues/119.

Ideally, we should be able to reference @isFakeAccount's Python library to better understand how to fit this into psn-api.