Skip to content
This repository has been archived by the owner on Jan 3, 2022. It is now read-only.

Messages #11

Open
frasza opened this issue Jun 18, 2018 · 2 comments
Open

Messages #11

frasza opened this issue Jun 18, 2018 · 2 comments

Comments

@frasza
Copy link

frasza commented Jun 18, 2018

Hey!

Looking for PSN Messaging API solution and I found your API but I am wondering, are you working on messaging part of API? :)

@mgp25
Copy link
Owner

mgp25 commented Jun 18, 2018

Hello @frasza,

Yes, that is something I was working on, but haven't had time to work on it lately. PSN Messaging now uses HTTP2.0, and this is what it looks like:

:method: POST
:path: /groupMessaging/v1/messageGroups/~xxxE837DyyyB2E5C.7F6zzz27ED000ECA/messages
:authority: es-gmsg.np.community.playstation.net
:scheme: https
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:59.0) Gecko/20100101 Firefox/59.0
accept: */*
accept-language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3
accept-encoding: gzip, deflate, br
content-type: multipart/mixed; boundary="---------------------------26061"
authorization: Bearer 15e000c-36p0-400a-8b53-e94e0009745f
content-length: 204
origin: https://my.playstation.com
dnt: 1


-----------------------------26061
Content-Type: application/json; charset=utf-8
Content-Description: message

{"message":{"messageKind":1,"body":"que tal?"}}
-----------------------------26061--

None of the python libs were supporting http2, unless hyper. I have opened an issue there python-hyper/hyper#380 (comment) where I asked if I was doing it right:

        boundary = "---------------------------"+str(random.sample(range(10000, 99999), 1)[0])

        header = {
            'origin': 'https://my.playstation.com',
            'Authorization': 'Bearer ' + self.oauth,
            'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:59.0) Gecko/20100101 Firefox/59.0',
            'Content-Type': 'multipart/mixed; boundary='+boundary,
            'accept-encoding': 'gzip, deflate, br',
            'accept': '*/*',
            'dnt': '1',

        }

        message_body = {
            "message": {
                "messageKind": 1,
                "body": message_text
            }
        }

        message = "\r\n"
        message += boundary+"\r\n"
        message += "Content-Type: application/json; charset=utf-8\r\n"
        message += "Content-Description: message\r\n"
        message += "\r\n"
        message += json.dumps(message_body) + "\r\n"
        message += boundary + "--\r\n"


        conn = HTTP20Connection("es-gmsg.np.community.playstation.net:443")
        request = conn.request('POST', "/groupMessaging/v1/messageGroups/"+thread_id+"/messages", headers=header, body=message)
        response = conn.get_response(request)
        print(response.read())

And the response I get from the code above is:

{"error":{"code":2121729,"message":"Bad request"}}

I think the function I posted above is right, but maybe it needs to be tweaked a bit yet.

Regards

@isFakeAccount
Copy link

Hi! Is there any progress on this? I could use the feature of sending messages. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants