[Python] How can I make a Roblox friend request?

Discussão em 'Python' iniciado por Stack, Dezembro 8, 2024.

  1. Stack

    Stack Membro Participativo

    Code changes for the changed Roblox Friends API

    I am trying to make a Roblox friend requester for Python, but this is not fully working to request a Roblox friend API.

    import requests

    rcookie = "Example Cookie" # Security COOKIE
    Target_ID = 1 # Roblox

    x_csrf_res = requests.post(
    url = "https://groups.roblox.com/v1/groups/1/users",
    cookies = {
    ".ROBLOSECURITY": rcookie
    }
    )

    if x_csrf_res.headers.get("x-csrf-token"):
    csrf = x_csrf_res.headers.get("x-csrf-token")
    test_res = requests.post(
    url = f"https://friends.roblox.com/v1/users/{Target_ID}/request-friendship",
    data = {
    "friendshipOriginSourceType": 0
    },
    headers = {
    "X-Csrf-Token": csrf
    },
    cookies = {
    ".ROBLOSECURITY": rcookie
    }
    )
    if test_res.status_code == 200:
    print("Send Friend!")
    print(test_res.text)
    else:
    print("Error!")
    print(test_res.status_code)
    print(test_res.text)
    else:
    print(f"Invalid Cookie! {x_csrf_res.status_code} {x_csrf_res.text}")


    Even if the response code is 200 in Roblox, the friend request is not requested.

    This is the proof photo.


    [​IMG]
    ​

    {
    "success": true,
    "notificationMuted": true
    }


    However, when requesting the same data to Postman, the retuned JSON is the following.

    {
    "success": true,
    "isCaptchaRequired": false
    }


    This successfully works to request a Roblox friend API and a friend request comes in the target Roblox user ID..

    How can I fix this problem?

    My code has been broken since the Roblox Friends API changed.

    Continue reading...

Compartilhe esta Página