Can I access my telegram's messages as json? [

2019-09-13 20:42发布

问题:

I'm trying to store all messages which are exist in my telegram application. For example all my private chats and all group's messages and channel's messages I'm a member of them.

I use PHP programming language. And I need to get all messages as .json (instead of seeing them into telegram application). Is doing that possible?

Based on some researched, I figured out it is possible by using Telegram API. But honestly it's vague for me. I don't know how should I start. Anyway, isn't there any implemented example of what I'm looking for? Or do you know how should I start?

回答1:

What you want to achieve is possible.

Let me give you a step by step walkthrough of how to do this. The directions below will work for any language of your choice.

  1. It is easy to gain access to all messages that are directed to your Telegram account. You would first need to build a Telegram client. To get started on this check out these two SO Posts for the background you need (but not in PHP)

  2. Successfully completing above step gets you Authorised on the Telegram Network, next step is to start listening for messages sent to your telegram account.

  3. By this point you have the basic code setup to receive messages ALL types of telegram messages sent to your account. What you need now is to convert the received messages to JSON and possibly store them to any database of your choice. This step should be easy for you to do.

The steps 1 & 2 above do most of the heavy lifting for you by converting the bytes received from Telegram into a format that is accessible to you in your chosen programing language, you simply need to convert to JSON at this point.

Hope this helps.



标签: php api telegram