LoginSignup
1
2

More than 3 years have passed since last update.

VRChatで自分をフレンドに追加する

Last updated at Posted at 2019-09-23

この記事について

柊 釘葉さんのVRChatのステータスをTwitterに表示するスプリクトtwitter-vrc-statusの導入で、自分自身をフレンドに追加するという部分の解説です。

コード

これをコピペして実行すればフレンドリクエストが届きます。
Python3が必要です。

AddFriendMyself.py
import json
import requests

API_BASE = "https://api.vrchat.cloud/api/1"

url = "{}/config".format(API_BASE)
response = requests.get(url)
apiKey = json.loads(response.text)["clientApiKey"]

from requests.auth import HTTPBasicAuth

USER     = "" #ここにVRChatのIDを入力
PASSWORD = "" #ここにパスワード

url = "{}/auth/user".format(API_BASE)
response = requests.get(url, 
                        params={"apiKey": apiKey},
                        auth=HTTPBasicAuth(USER, PASSWORD))
token = response.cookies["auth"]
uid = json.loads(response.text)["id"]


url = "{0}/user/{1}/friendRequest".format(API_BASE, uid)
requests.post(url, 
                        params={"apiKey": apiKey, "authToken": token})

ここでつまった

VRChat APIのIDをログイン時のIDだと勘違いしていて3日悩みました。

参考

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2