Telegram Bot API
🌐 Türkçe

setChatPhoto

Kategori: Sohbet · Bot API 10.3 · Resmi dokümantasyon

Sohbet fotoğrafını ayarlar.

Dönüş değeri: Başarılı olduğunda True döndürür.

Parametreler

ParametreTürZorunluAçıklama
chat_idInteger or StringEvetSohbet ID'si
photoInputFileEvetYeni sohbet fotoğrafı URL'si veya file_id

Parametre açıklamaları kısa özetlerdir; tam metin için resmi dokümantasyona bakın.

Örnek istek

curl

curl -s "https://api.telegram.org/bot$TOKEN/setChatPhoto" \
  -F chat_id=123456789 \
  -F photo=@photo.jpg

Python

import requests

TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
    f"https://api.telegram.org/bot{TOKEN}/setChatPhoto",
    data={
        "chat_id": 123456789
    },
    files={"photo": open("photo.jpg", "rb")},
    timeout=30,
)
print(resp.json())

JavaScript

import { readFile } from "node:fs/promises";

const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const form = new FormData();
form.append("chat_id", "123456789");
form.append("photo", new Blob([await readFile("photo.jpg")]), "photo.jpg");
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/setChatPhoto`, { method: "POST", body: form });
console.log(await res.json());

Adım adım rehber: Telegram bot nasıl yapılır? BotFather ile adım adım bot oluşturma