所以我正在使用访问Groupme API的请求(在此处https://dev.groupme.com/docs/v3中找到),并且我正在尝试向特定组发布文本(创建消息)。我进入了特定的组API,但是当我阅读文档时,它说要输入2个参数,而我却得到500错误。
这是我正在查看的部分的groupme api文档
Send a message to a group
If you want to attach an image, you must first process it through our image service.
Attachments of type emoji rely on data from emoji PowerUps.
Clients use a placeholder character in the message text and specify a replacement charmap to substitute emoji characters
The character map is an array of arrays containing rune data ([[{pack_id,offset}],...]).
The placeholder should be a high-point/invisible UTF-8 character.
Request
POST /groups/:group_id/messages
{
"message": {
"source_guid": "GUID",
"text": "Hello world ☃☃",
"attachments": [
{
"type": "image",
"url": "https://i.groupme.com/123456789"
},
{
"type": "image",
"url": "https://i.groupme.com/123456789"
},
{
"type": "location",
"lat": "40.738206",
"lng": "-73.993285",
"name": "GroupMe HQ"
},
{
"type": "split",
"token": "SPLIT_TOKEN"
},
{
"type": "emoji",
"placeholder": "☃",
"charmap": [
[
1,
42
],
[
2,
34
]
]
}
]
}
}
Parameters
source_guid required
string — Client-side IDs for messages. This can be used by clients to set their own identifiers on messages, but the server also scans these for de-duplication. That is, if two messages are sent with the same source_guid within one minute of each other, the second message will fail with a 409 Conflict response. So it's important to set this to a unique value for each message.
text required
string — This can be omitted if at least one attachment is present. The maximum length is 1,000 characters.
attachments
array — A polymorphic list of attachments (locations, images, etc). You may have You may have more than one of any type of attachment, provided clients can display it.
object
type (string) — “image” required
url (string) required — Must be an image service (i.groupme.com) URL
object
type (string) — “location” required
name (string) required
lat (string) required
lng (string) required
object
type (string) — “split” required
token (string) required
object
type (string) — “emoji” required
placeholder (string) — “☃” required
charmap (array) — “[{pack_id},{offset}]” required
这是我的代码(我用KEY替换了API密钥):
import requests
import uuid
# group me api post
GroupMeURL = "https://api.groupme.com/v3/groups/31713838/messages?token=KEY"
GUID = uuid.uuid4()
GUID = str(GUID)
data = {"source_guid": GUID, "text": "test"}
postWeather = requests.post(url=GroupMeURL, data=data)
[如果有人可以给我建议,将不胜感激