40 lines
2.1 KiB
Plaintext
40 lines
2.1 KiB
Plaintext
#register user
|
|
curl -X POST -d '{"username":"<name>", "password":"<password>", "auth": {"type":"m.login.dummy"}}' "https://<homeserver>/_matrix/client/r0/register"
|
|
|
|
#set display name
|
|
curl -X PUT -d '{"displayname": "<name>"}' "https://<homeserver>/_matrix/client/r0/profile/@<userid>:<homeserver>/displayname?access_token=<>"
|
|
|
|
#set profile picture
|
|
curl -X PUT -d '{"avatar_url": "mxc://<homeserver>/<media_id>"}' "https://<homeserver>/_matrix/client/unstable/profile/@<user_id>:<homeserver>/avatar_url?access_token=<>"
|
|
|
|
#get server login methods
|
|
curl -X GET "https://<homeserver>/_matrix/client/r0/login"
|
|
|
|
#get access token
|
|
curl -X POST -d '{"type":"m.login.password", "user":"<username>", "password":"<password>"}' "https://<homeserver>/_matrix/client/r0/login"
|
|
|
|
#list joined rooms
|
|
curl -X GET "https://<homeserver>/_matrix/client/r0/joined_rooms?access_token=<>"
|
|
|
|
#create room
|
|
curl -X POST -d '{"name": "<room name>", "room_alias_name":"<unique_alias>"}' "https://<homeserver>/_matrix/client/r0/createRoom?access_token=<>"
|
|
|
|
#get room events
|
|
curl -X GET "https://<homeserver>/_matrix/client/r0/rooms/"'!'"<room_id>:<homeserver>/state?access_token=<>"
|
|
|
|
#upload file (image)
|
|
curl -X POST -H "Content-Type: image/<image type (png/jpeg)>" --data-binary @<filename> "https://<homeserver>/_matrix/media/r0/upload?access_token=<>&filename=<filename>"
|
|
|
|
#send image to room
|
|
#there is no way to caption an image at the moment, so you have to either send a separate message
|
|
#or set the filename as the caption
|
|
curl -X POST -d '{"body": "<text content/filename>","info": {"mimetype": "image/<image_type (png/jpeg)>"},"msgtype": "m.image","url": "mxc://<homeserver>/<media_id>"}' "https://<homeserver>/_matrix/client/r0/rooms/"'!'"<room_id>:<homeserver>/send/m.room.message?access_token=<>"
|
|
|
|
#send text to room
|
|
curl -X POST -d '{"body": "text", "msgtype": "m.text"}' "https://<homeserver>/_matrix/client/r0/rooms"'!'"<room_id>:<homeserver>/send/m.room.message?access_token=<>"
|
|
|
|
#use the sync api to get message updates
|
|
|
|
#get room name if it exists
|
|
curl -XGET 'https://<homeserver>/_matrix/client/r0/rooms/<roomid>/state/m.room.name?access_token=<>'
|