Telegram-Mini-Apps / telegram-apps

Made from scratch TypeScript packages, examples and documentation you will surely need to start developing on Telegram Mini Apps.

Home Page:https://docs.telegram-mini-apps.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: CAN NOT USE photoUrl from user with mockTelegramEnv

fukemy opened this issue · comments

Telegram Application

Other

Describe the Bug

I follow the website document:

import { mockTelegramEnv, parseInitData } from "@telegram-apps/sdk-react";



const initDataRaw = new URLSearchParams([
    ['user', JSON.stringify({
        id: -99281932,
        first_name: 'Andrew',
        last_name: 'Rogue',
        username: 'rogue',
        language_code: 'en',
        is_premium: false,
        photoUrl: 'https://avatars.githubusercontent.com/u/8202437',
        allows_write_to_pm: true,
    })],
    ['hash', '89d6079ad6762351f38c6dbbc41bb53048019256a9443988af7a48bcad16ba31'],
    ['auth_date', '1716922846'],
    ['start_param', 'debug'],
    ['chat_type', 'sender'],
    ['chat_instance', '8428209589180549439'],
]).toString();

export default function generateTelegramMockup() {
    mockTelegramEnv({
        themeParams: {
            accentTextColor: '#6ab2f2',
            bgColor: '#17212b',
            buttonColor: '#5288c1',
            buttonTextColor: '#ffffff',
            destructiveTextColor: '#ec3942',
            headerBgColor: '#17212b',
            hintColor: '#708499',
            linkColor: '#6ab3f3',
            secondaryBgColor: '#232e3c',
            sectionBgColor: '#17212b',
            sectionHeaderTextColor: '#6ab3f3',
            subtitleTextColor: '#708499',
            textColor: '#f5f5f5',
        },
        initData: parseInitData(initDataRaw),
        initDataRaw,
        version: '7.2',
        platform: 'tdesktop',
    });
}

But when get initData, I can not see the photoUrl. Tried with clear cache, delete .next folder(NextJS)...

To Reproduce

Steps to reproduce the behavior:

  1. Apply document code https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk/environment
  2. Get InitData

Expected Behavior

I want to get photoUrl with mockTelegramEnv

I tested with mini app version from MacOS but still can not get photoUrl

Because it should be photo_url.

i checked initData but can not find this, no photo_url even I have this

Mocking init data, you must use this data:

const initDataRaw = new URLSearchParams([
    ['user', JSON.stringify({
        id: -99281932,
        first_name: 'Andrew',
        last_name: 'Rogue',
        username: 'rogue',
        language_code: 'en',
        is_premium: false,
        photo_url: 'https://avatars.githubusercontent.com/u/8202437',
        allows_write_to_pm: true,
    })],
    ['hash', '89d6079ad6762351f38c6dbbc41bb53048019256a9443988af7a48bcad16ba31'],
    ['auth_date', '1716922846'],
    ['start_param', 'debug'],
    ['chat_type', 'sender'],
    ['chat_instance', '8428209589180549439'],
]).toString();

Anyways, why do you need it? It is only accessible to Telegram partners