MisskeyというSNSを学部内で利用していて、そのbotを作成しようとしています。
APIドキュメントはこんな感じです(エラーメッセージの下)
Responseの受信の実装がよくわりません
それと、下記(一番下)のコードを実行すると次のようなエラーがでます。検索して調べてみましたが
解決に至りませんでした
Traceback (most recent call last): File "c:/Users/user/Desktop/Misskey/sample.py", line 36, in <module> main() File "c:/Users/user/Desktop/Misskey/sample.py", line 32, in main resdata = response.json() File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\models.py", line 898, in json return complexjson.loads(self.text, **kwargs) File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\json\__init__.py", line 357, in loads return _default_decoder.decode(s) File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)
###Request samples
Payload
Content type:application/json
{
"limit": 10,
"offset": 0,
"sort": "+follower",
"state": "all",
"origin": "local"
}
###Response samples
Content type:application/json
{
"id": "xxxxxxxxxx",
"username": "ai",
"name": "藍",
"url": "string",
"avatarUrl": "string",
"avatarBlurhash": null,
"bannerUrl": "string",
"bannerBlurhash": null,
"emojis": null,
"host": "misskey.example.com",
"description": "Hi masters, I am Ai!",
"birthday": "2018-03-12",
"createdAt": "2019-08-24T14:15:22Z",
"updatedAt": "2019-08-24T14:15:22Z",
"location": "string",
"followersCount": 0,
"followingCount": 0,
"notesCount": 0,
"isBot": true,
"pinnedNoteIds": [],
"pinnedNotes": [],
"isCat": true,
"isAdmin": true,
"isModerator": true,
"isLocked": true,
"hasUnreadSpecifiedNotes": true,
"hasUnreadMentions": true
}
python3
1 2from Misskey import Misskey 3import requests 4import json 5 6class Cisskey(Misskey): 7 @property 8 def apiToken(self): 9 return self.__apiToken 10 11 @apiToken.setter 12 def apiToken(self, val): 13 self.__apiToken = val 14 15 def __init__(self, addr, i): 16 self.headers["X-CISSKEY-KEY"] = "XXX" 17 super().__init__(addr, i) 18 19 20def main(): 21 22 data= { 23 "limit": 100, 24 "offset": 0, 25 "sort": "+follower", 26 "state": "all", 27 "origin": "local" 28 } 29 30 #dataをPOST 31 response = requests.post( 32 url="POST_URL",json=json.dumps(data) 33 ) 34 resdata = response.json() 35 36if __name__ == '__main__': 37 main() 38 39 40
回答1件
あなたの回答
tips
プレビュー